Package org.zoolu.sip.transaction

Examples of org.zoolu.sip.transaction.TransactionServer


                        if (optBody!=null)
                        {
                          optStat=200;
                          // add capabilities to msg to be sent
                         printLog("OPTION Request - response status="+optStat , LogLevel.HIGH);
                         TransactionServer ts=new TransactionServer(this,msg,null);
                        ts.respondWith(MessageFactory.createResponse(msg,optStat,SipResponses.reasonOf(optStat),null,null,"application/sdp",optBody));
                      return;
                        }
                      }
                      else
                      optStat=200; // assume available if no option handler
                }

                 printLog("OPTION Request - response status="+optStat,LogLevel.MEDIUM );
                 TransactionServer ts=new TransactionServer(this,msg,null);
                   ts.respondWith(MessageFactory.createResponse(msg,optStat,SipResponses.reasonOf(optStat),null));
                return;
         }

    // try to look for a transaction
         Identifier key=msg.getTransactionId();
         printLog("DEBUG: transaction-id: "+key,LogLevel.MEDIUM);
         if (listeners.containsKey(key))
         {  printLog("message passed to transaction: "+key,LogLevel.MEDIUM);
            ((SipProviderListener)listeners.get(key)).onReceivedMessage(this,msg);
            return;
         }
         // try to look for a dialog
         key=msg.getDialogId();
         printLog("DEBUG: dialog-id: "+key,LogLevel.MEDIUM);
         if (listeners.containsKey(key))
         {  printLog("message passed to dialog: "+key,LogLevel.MEDIUM);
            ((SipProviderListener)listeners.get(key)).onReceivedMessage(this,msg);
            return;
         }
         // try to look for a UAS
         key=msg.getMethodId();
         if (msg.isRequest() && msg.isInvite())
              {
               // need to synchronize invite requests to avoid issues
               synchronized (inviteLock)
          {
         if (listeners.containsKey(key))
         {  printLog("message passed to uas: "+key,LogLevel.MEDIUM);
            ((SipProviderListener)listeners.get(key)).onReceivedMessage(this,msg);
            return;
         }
           }
              }
              else if (listeners.containsKey(key))
              {
               printLog("message passed to uas: "+key ,LogLevel.LOW);
                 ((SipProviderListener)listeners.get(key)).onReceivedMessage(this,msg);
                 return;
         }



         // try to look for a default UA
         if (listeners.containsKey(ANY))
         {  printLog("message passed to uas: "+ANY,LogLevel.MEDIUM);
            ((SipProviderListener)listeners.get(ANY)).onReceivedMessage(this,msg);
            return;
         }

         if (msg.isRequest() && msg.isInvite())
         {
           // we are busy or can't answer - Invite would have been picked up above already if we could handle it

           if (sipBusyUrl!=null)
           {
             // redirect the call elsewhere
             String targetId=msg.getToHeader().getNameAddress().toString().replaceAll("(?i).*sip:<?([^@<]+)@.*", "$1");
             String redirect_Url=sipBusyUrl.replaceAll("calleeid", targetId);

                printLog("Incoming SIP Call - Channel busy - Redirect to: "+redirect_Url ,LogLevel.LOW);

                Message resp=MessageFactory.createResponse(msg,302,SipResponses.reasonOf(302),new NameAddress(redirect_Url));
               InviteTransactionServer ts=new InviteTransactionServer(this,msg,null);
                 ts.respondWith(resp);
              return;
           }

            printLog("Invite Request - Sending busy response (486)",LogLevel.MEDIUM);
            InviteTransactionServer ts=new InviteTransactionServer(this,msg,null);
              ts.respondWith(MessageFactory.createResponse(msg,486,SipResponses.reasonOf(486),null));
           return;
         }

         if (msg.isRequest() && msg.isNotify())
         {
           // nobody handled it, just respond 405 (method not allowed) to get it to go away
            printLog("Notify Request - Sending unsupported response (405)",LogLevel.MEDIUM);
            TransactionServer ts=new TransactionServer(this,msg,null);
              ts.respondWith(MessageFactory.createResponse(msg,405,SipResponses.reasonOf(405),null));
           return;
         }

        // if we are here, no listener_ID matched..
         printLog("No SipListener found matching that message: message DISCARDED",LogLevel.HIGH);
View Full Code Here


   /** When a new request is received for the local server. */
   public void processRequestToLocalServer(Message msg)
   { 
      printLog("inside processRequestToLocalServer(msg)",LogLevel.MEDIUM);
      if (server_profile.is_registrar && msg.isRegister())
      {  TransactionServer t=new TransactionServer(sip_provider,msg,null);
         //t.listen();
  
         if (server_profile.do_authentication)
         {  // check message authentication
            Message err_resp=as.authenticateRequest(msg)
            if (err_resp!=null)
            {  t.respondWith(err_resp);
               return;
            }
         }
        
         Message resp=updateRegistration(msg);
         if (resp==null) return;
        
         if (server_profile.do_authentication)
         {  // add Authentication-Info header field
            resp.setAuthenticationInfoHeader(as.getAuthenticationInfoHeader());
         }
        
         t.respondWith(resp);
      }
      else
      if (!msg.isAck())
      {  // send a stateless error response
         int result=501; // response code 501 ("Not Implemented")
View Full Code Here

TOP

Related Classes of org.zoolu.sip.transaction.TransactionServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.