Thursday Apr 29, 2010

Call Forwarding in SailFin CAFE

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.

About

Mohit Gupta

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today