SailFin CAFE makes call-forwarding apps much much simpler !!


1. The following describes, how all the incoming calls to Alice are forwarded to Bob:


@CommunicationBean
public class CommsBean {


@CommunicationEvent(type = CommunicationEvent.Type.INITIALIZATION)
void handleInit() {
Conversation call = (Conversation) ctx.getCommunication();
if(call.getCallee().getName().equals("alice@example.com")) {
call.removeParticipant(call.getCallee());
call.addParticipant("bob@example.com");
}
}


}



2. In case Alice takes up the call and then wants to forward it to a selected user, the code will look like:


@CommunicationEvent(type=Type.MESSAGEARRIVED)
public void handleMessageArrived(){
Conversation call=(Conversation)ctx.getCommunication();
DtmfSignal ds=(DtmfSignal)ctx.getMessage();
if(ds.getSignal().equals("3")){
UserParticipant part=(UserParticipant)call.getCallee();
if(part.getName().equals("alice@example.com")){
call.removeParticipant(call.getCallee());
call.addParticipant("bob@example.com");
}
}
}


Sample application can be downloaded from here.




Read More about [Call Forwarding in SailFin CAFE...