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.

Comments:

i have just downloaded this sample and build it successfully in netbeans and have registered two users Bob and Alicebut my problem is how do i actually test the sample do i call directly from the registered softphones or what?need to understand more please help!

Posted by gloria on June 09, 2010 at 02:00 AM PDT #

i have just downloaded this sample and build it successfully in netbeans and have registered two users Bob and Alice but my problem is how do i actually test the sample do i call directly from the registered softphones or what?need to understand more please help!

Posted by Gloria on June 09, 2010 at 02:01 AM PDT #

Hi Gloria,

For testing the sample, once you have alice and bob registered, you can try to make a call from alice's softphone to some user(lets say ted@example.com), the call will invoke the communication bean's init method(Case 1 above), where bob will be set as callee instead of ted leading the call to be forwarded to bob@example.com

Posted by Mohit Gupta on June 09, 2010 at 02:38 PM PDT #

thanks for responding but i want to test case 2 the one that uses DTMF how do i test it?both my phones are registered.

Posted by Gloria on June 17, 2010 at 12:33 AM PDT #

for case 2, you just need to intercept the DTMF signal using MessageArrived CommunicationEvent. For this case to work send the DTMF signal from phone once the call is establised.

ps: in the sample attached above, you will need to comment the code in handleinit method, so that case 1 is not executed.

Posted by Mohit Gupta on June 17, 2010 at 02:59 PM PDT #

The first example is working, but he second example is not working in following case:

when I establish successful connection, for example as alice@somedomain.local with ernie@somedomain.local (somedomain.local is some domain I set up in my LAN) and send an DTMF message from alice@somedomain.local, the handler properly removes the callee and adds bert@somedomain.local. But after the handler execution this exception pops out "from nowhere":

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.glassfish.cafe.core.statemachine.transition.STTBuilder$1.transition(STTBuilder.java:73)
at org.glassfish.cafe.core.statemachine.StateMachine.run(StateMachine.java:66)
at org.glassfish.cafe.core.statemachine.transition.conversation.Conversation.runParticipantSM(Conversation.java:887)
at org.glassfish.cafe.core.statemachine.transition.conversation.Conversation.runParticipantSM(Conversation.java:894)
at org.glassfish.cafe.core.statemachine.transition.conversation.Conversation.__replaceReady(Conversation.java:614)
at org.glassfish.cafe.core.statemachine.transition.conversation.Conversation.replaceReady(Conversation.java:156)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.glassfish.cafe.core.statemachine.transition.STTBuilder$1.transition(STTBuilder.java:73)
at org.glassfish.cafe.core.statemachine.StateMachine.run(StateMachine.java:66)
at org.glassfish.cafe.core.statemachine.StateMachine.run(StateMachine.java:37)
at org.glassfish.cafe.core.CommunicationImpl.__runStateMachine(CommunicationImpl.java:449)
at org.glassfish.cafe.core.CafeBeanContainer.handleOperationInput(CafeBeanContainer.java:83)
at org.glassfish.cafe.core.CommunicationImpl.__handleAddParticipant(CommunicationImpl.java:87)
at org.glassfish.cafe.core.ConversationImpl.clearParticipant(ConversationImpl.java:59)
at org.glassfish.cafe.core.statemachine.transition.conversation.Conversation.__replaceReady(Conversation.java:703)
at org.glassfish.cafe.core.statemachine.transition.conversation.Conversation.replaceReady(Conversation.java:166)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.glassfish.cafe.core.statemachine.transition.STTBuilder$1.transition(STTBuilder.java:73)
at org.glassfish.cafe.core.statemachine.StateMachine.run(StateMachine.java:66)
at org.glassfish.cafe.core.statemachine.StateMachine.run(StateMachine.java:37)
at org.glassfish.cafe.core.CommunicationImpl.__runStateMachine(CommunicationImpl.java:449)
at org.glassfish.cafe.core.CommunicationImpl.__runStateMachine(CommunicationImpl.java:428)
at org.glassfish.cafe.core.CommunicationImpl.handleResponse(CommunicationImpl.java:457)
at org.glassfish.cafe.core.CafeBeanContainer.handleResponse(CafeBeanContainer.java:329)
at org.glassfish.cafe.core.Servlet.doResponse(Servlet.java:71)
at javax.servlet.sip.SipServlet.service(SipServlet.java:48)
at com.ericsson.ssa.container.sim.SipServletFacade.service(SipServletFacade.java:121)
at com.ericsson.ssa.sip.INVITESession.dispatch(INVITESession.java:854)
at com.ericsson.ssa.sip.UA.dispatch(UA.java:720)
at com.ericsson.ssa.container.sim.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:601)
at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:71)
at com.ericsson.ssa.container.sim.ApplicationDispatcher.next(ApplicationDispatcher.java:704)
at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:78)
at com.ericsson.ssa.sip.LocalRouteManager.next(LocalRouteManager.java:106)
at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:78)
at com.ericsson.ssa.sip.DialogManager.next(DialogManager.java:749)
at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:78)
at com.ericsson.ssa.sip.dns.ResolverManager.next(ResolverManager.java:276)
at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:78)
at com.ericsson.ssa.sip.persistence.ReplicationManager.next(ReplicationManager.java:124)
at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:78)
at com.ericsson.ssa.sip.transaction.TransactionManager.next(TransactionManager.java:374)
at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:78)
at com.ericsson.ssa.container.OutboundFlowManager.next(OutboundFlowManager.java:258)
at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:78)
at com.ericsson.ssa.container.GrizzlyNetworkManager.next(GrizzlyNetworkManager.java:1335)
at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:78)
at com.ericsson.ssa.container.MessageProcessorFilter.processMessage(MessageProcessorFilter.java:464)
at com.ericsson.ssa.container.MessageProcessorFilter.execute(MessageProcessorFilter.java:303)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:136)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89)
at com.ericsson.ssa.container.GrizzlyNetworkManager$SharedCallbackHandler.onRead(GrizzlyNetworkManager.java:3136)
at com.sun.grizzly.CallbackHandlerContextTask.doCall(CallbackHandlerContextTask.java:76)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:56)
at com.sun.grizzly.util.WorkerThreadImpl.processTask(WorkerThreadImpl.java:325)
at com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:184)
Caused by: java.lang.IllegalStateException: SipSession is not valid.
at com.ericsson.ssa.sip.SipSessionImplBase.validateSessionState(SipSessionImplBase.java:256)
at com.ericsson.ssa.sip.SipSessionImplBase.getState(SipSessionImplBase.java:1120)
at com.ericsson.ssa.sip.SipSessionImplBase.getState(SipSessionImplBase.java:1115)
at com.ericsson.ssa.sip.B2buaHelperImpl.isTerminated(B2buaHelperImpl.java:791)
at com.ericsson.ssa.sip.B2buaHelperImpl.linkSipSessions(B2buaHelperImpl.java:760)
at org.glassfish.cafe.core.statemachine.agent.ParticipantAgent.inviteNewParty(ParticipantAgent.java:590)
at org.glassfish.cafe.core.statemachine.transition.conversation.ReplacingParty.__initial(ReplacingParty.java:67)
at org.glassfish.cafe.core.statemachine.transition.conversation.ReplacingParty.initial(ReplacingParty.java:30)
... 67 more

I am using sailfin v2 b31g on linux with sailfin-cafe v1 b34.

Posted by Trg on September 24, 2010 at 01:21 AM PDT #

Hi Trg,

It looks like a bug in sailfin cafe. Can you please send a mail to sailfin users mail listing - users@sailfin.dev.java.net Please attach the above log with the mail.

thanks
Mohit

Posted by Mohit Gupta on September 27, 2010 at 03:51 PM PDT #

I fixed this regression yesterday and the fix is available in the latest nightly build.

Posted by Binod on September 28, 2010 at 11:05 AM PDT #

Hi,
Can some one tell ne how the sip registration works with Sailfin cafe?
I mean where to set up the users (let say username, password for authentication)
I did not test the system (sailfin cafe) yet but I am wondering where the system stores the IP address/port for SIP users, after a registration process?
Thanks.

Posted by Bensari on December 13, 2010 at 11:23 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
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