Package org.zoolu.sip.message

Examples of org.zoolu.sip.message.Message


   //************************* Callback methods *************************
  
   /** When a new UDP datagram is received. */
   public void onReceivedPacket(UdpProvider udp, UdpPacket packet)
   {  Message msg=new Message(packet);
      msg.setRemoteAddress(packet.getIpAddress().toString());
      msg.setRemotePort(packet.getPort());
      msg.setTransport(PROTO_UDP);
      if (listener!=null) listener.onReceivedMessage(this,msg);
   }  
View Full Code Here


  protected static Logger log = Red5LoggerFactory.getLogger( OptionMethodListener.class, "sip" );
 
  public void onReceivedMessage(SipProvider sip_provider, Message message) {
    if (message.isOption()) {
      log.debug("Received OPTION message");
      Message response = MessageFactory.createResponse(message, 200, "OK", message.getFromHeader().getNameAddress());
      sip_provider.sendMessage(response);
    }
  }
View Full Code Here

             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;
           }

View Full Code Here

   /** Inits the KeepAliveSip in SIP mode */
   private void init(SipProvider sip_provider, Message message)
   {  this.sip_provider=sip_provider;
      if (message==null)
      {  message=new Message("\r\n");
      }
      //if (target!=null)
      //{  message.setRemoteAddress(target.getAddress().toString());
      //   message.setRemotePort(target.getPort());
      //}
View Full Code Here

     * @param local_tag   tag in FromHeader
     * @param remote_tag  tag in ToHeader (if null, no tag is added)
     * @param branch      branch value (if null, a random value is picked)
     * @param body        body (if null, no body is added) */
   public static Message createRequest(String method, SipURL request_uri, NameAddress to, NameAddress from, NameAddress contact, String proto, String via_addr, int host_port, boolean rport, String call_id, long cseq, String local_tag, String remote_tag, String branch, String body)
   {  Message req=new Message();
      //mandatory headers first (To, From, Via, Max-Forwards, Call-ID, CSeq):
      req.setRequestLine(new RequestLine(method,request_uri));
      ViaHeader via=new ViaHeader(proto,via_addr,host_port);
      if (rport) via.setRport();
      if (branch==null) branch=SipProvider.pickBranch();
      via.setBranch(branch);
      req.addViaHeader(via);
      req.setMaxForwardsHeader(new MaxForwardsHeader(70));
      if (remote_tag==null) req.setToHeader(new ToHeader(to));
         else req.setToHeader(new ToHeader(to,remote_tag));
      req.setFromHeader(new FromHeader(from,local_tag));
      req.setCallIdHeader(new CallIdHeader(call_id));
      req.setCSeqHeader(new CSeqHeader(cseq,method));
      //optional headers:
      if (contact!=null)
      {  MultipleHeader contacts=new MultipleHeader(SipHeaders.Contact);
         contacts.addBottom(new ContactHeader(contact));
         //System.out.println("DEBUG: Contact: "+contact.toString());
         req.setContacts(contacts);
      }
      req.setExpiresHeader(new ExpiresHeader(String.valueOf(SipStack.default_expires)));
      // add User-Agent header field
      if (SipStack.ua_info!=null) req.setUserAgentHeader(new UserAgentHeader(SipStack.ua_info));
      //if (body!=null) req.setBody(body); else req.setBody("");
      req.setBody(body);
      //System.out.println("DEBUG: MessageFactory: request:\n"+req);
      return req;
   }
View Full Code Here

      String call_id=dialog.getCallID();
      long cseq=dialog.getLocalCSeq();
      String local_tag=dialog.getLocalTag();
      String remote_tag=dialog.getRemoteTag();
      //String branch=SipStack.pickBranch();
      Message req=createRequest(method,request_uri,to,from,contact,proto,via_addr,host_port,rport,call_id,cseq,local_tag,remote_tag,null,body);
      Vector route=dialog.getRoute();
      if (route!=null && route.size()>0)
         req.addRoutes(new MultipleHeader(SipHeaders.Route,route));
      req.rfc2543RouteAdapt();
      return req;
   }
View Full Code Here

        String call_id=dialog.getCallID();
        long cseq=dialog.getLocalCSeq();
        String local_tag=dialog.getLocalTag();
        String remote_tag=dialog.getRemoteTag();
        //String branch=SipStack.pickBranch();
        Message req=createRequest(method,request_uri,to,from,contact,proto,via_addr,host_port,rport,call_id,cseq,local_tag,remote_tag,null,body);
        Vector route=dialog.getRoute();
        if (route!=null && route.size()>0)
           req.addRoutes(new MultipleHeader(SipHeaders.Route,route));
        req.rfc2543RouteAdapt();
        return req;
   }
View Full Code Here

      String proto;
      if (request_uri.hasTransport()) proto=request_uri.getTransport();
      else proto=sip_provider.getDefaultTransport();
      String branch=method.getViaHeader().getBranch();
      NameAddress contact=null;
      Message ack=createRequest(SipMethods.ACK,request_uri,to.getNameAddress(),from.getNameAddress(),contact,proto,via_addr,host_port,rport,method.getCallIdHeader().getCallId(),method.getCSeqHeader().getSequenceNumber(),from.getParameter("tag"),to.getParameter("tag"),branch,null);
      ack.removeExpiresHeader();
      if (method.hasRouteHeader()) ack.setRoutes(method.getRoutes());
      return ack;
   }
View Full Code Here

   }


   /** Creates a BYE request. */
   public static Message createByeRequest(Dialog dialog)
   {  Message msg=createRequest(dialog,SipMethods.BYE,null);
      msg.removeExpiresHeader();
      msg.removeContacts();
      return msg;
   }
View Full Code Here

      else proto=sip_provider.getDefaultTransport();
      String call_id=sip_provider.pickCallId();
      int cseq=SipProvider.pickInitialCSeq();
      String local_tag=SipProvider.pickTag();
      //String branch=SipStack.pickBranch();
      Message req=createRequest(SipMethods.REGISTER,registrar,to,from,contact,proto,via_addr,host_port,rport,call_id,cseq,local_tag,null,null,null);
      // if no contact, deregister all
      if (contact==null)
      {  ContactHeader star=new ContactHeader(); // contact is *
         req.setContactHeader(star);
         req.setExpiresHeader(new ExpiresHeader(String.valueOf(SipStack.default_expires)));
      }
      return req;
   }
View Full Code Here

TOP

Related Classes of org.zoolu.sip.message.Message

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.