Examples of SipParser


Examples of org.cipango.sip.SipParser

    public void run()
    {
      EventHandler handler = new EventHandler();
      Buffer buffer = newBuffer(DEFAULT_TCP_MESSAGE);
     
      SipParser parser = new SipParser(buffer, this, handler);

      try
      {
        connectionOpened(this);
       
        SipMessage message = null;
       
        while (isStarted() && !isClosed())
        {
          int size = DEFAULT_TCP_MESSAGE;
          boolean overflow = false;
           
          do
          {
            overflow = false;
            try
            {
              parser.parse();
              size = DEFAULT_TCP_MESSAGE;
              parser.setBuffer(newBuffer(size));
            }
            catch (BufferOverflowException e)
            {
              //System.out.println("Overflow");
              overflow = true;
              size = size * 2;
              if (size > MAX_TCP_MESSAGE)
                throw new IOException("Message too large");
              Buffer extended = newBuffer(size);
              parser.setBuffer(extended, true);
            }
          }
          while (overflow);
         
          message = handler.getMessage();
          message.setConnection(this);

          /*message.set5uple(
              getTransportOrdinal(),
              getLocalAddress(),
              getLocalPort(),
              getRemoteAddress(),
              getRemotePort());
         
          if (message.isRequest())
            ((SipRequest) message).setEndpoint(this);*/
         
          process(message);
        }
      }
      catch (EofException e)
      {
        //System.out.println(parser.getState());
        Log.debug("EOF: {}", this);
        try
        {
          close();
        }
        catch (IOException e2)
        {
          Log.ignore(e2);
        }
      }
     
      catch (Throwable e)
      {
        System.out.println(parser.getState());
        if (_statsStartedAt != -1)
        {
          synchronized (_statsLock)
          {
            _nbParseErrors++;
View Full Code Here

Examples of org.zoolu.sip.provider.SipParser

   public int getExpires()
   {  int secs=-1;
      String exp_param=getParameter("expires");
      if (exp_param!=null)
      {  if (exp_param.indexOf("GMT")>=0)
         {  Date date=(new SipParser((new Parser(exp_param)).getStringUnquoted())).getDate();
            secs=(int)((date.getTime()-System.currentTimeMillis())/1000);
            if (secs<0) secs=0;
         }
         else secs=(new SipParser(exp_param)).getInt();
      }
      return secs;
   }
View Full Code Here

Examples of org.zoolu.sip.provider.SipParser

   public Date getExpiresDate()
   {  Date date=null;
      String exp_param=getParameter("expires");
      if (exp_param!=null)
      {  if (exp_param.indexOf("GMT")>=0)
         {  date=(new SipParser((new Parser(exp_param)).getStringUnquoted())).getDate();
         }
         else
         long secs=(new SipParser(exp_param)).getInt();
            if (secs>=0) date=new Date(System.currentTimeMillis()+secs*1000);
         }
      }
      return date;
   }
View Full Code Here

Examples of org.zoolu.sip.provider.SipParser

   super(SipHeaders.CSeq,String.valueOf(seq)+" "+method);
   }

   /** Gets method of CSeqHeader */
   public String getMethod()
   {  SipParser par=new SipParser(value);
      par.skipString(); // skip sequence number
      return par.getString();
   }
View Full Code Here

Examples of org.zoolu.sip.provider.SipParser

      return par.getString();
   }

   /** Gets sequence number of CSeqHeader */
   public long getSequenceNumber()
   {  return (new SipParser(value)).getInt();
   }
View Full Code Here

Examples of org.zoolu.sip.provider.SipParser

   }
  
   /** Whether has parameter <i>param_name</i> */
   public boolean hasParameter(String param_name)
   {  char[] name_separators={'='' ', '\t', '\r', '\n'};
      SipParser par=new SipParser(value);
      //par.skipString(); // skip the auth_scheme
      par.skipWSPCRLF();
      while (par.hasMore())
      {  String name=par.getWord(name_separators);
         if (name.equals(param_name)) return true;
         par.goToCommaHeaderSeparator().skipChar().skipWSPCRLF();
      }
      return false;
   }
View Full Code Here

Examples of org.zoolu.sip.provider.SipParser

   }
   /** Returns the parameter <i>param_name</i>, in case removing quotes. */
   public String getParameter(String param_name)
   {  char[] name_separators={'=', ' ', '\t'};
      SipParser par=new SipParser(value);
      //par.skipString(); // skip the auth_scheme
      par.skipWSPCRLF();
      while (par.hasMore())
      {  String name=par.getWord(name_separators);
         if (name.equals(param_name))
         {  par.goTo('=').skipChar().skipWSP();
            int comma=par.indexOfCommaHeaderSeparator();
            if (comma>=0)
               par=new SipParser(par.getString(comma-par.getPos()));
            return par.getStringUnquoted();
         }
         else par.goToCommaHeaderSeparator().skipChar().skipWSPCRLF();
      }
      return null;
   }
View Full Code Here

Examples of org.zoolu.sip.provider.SipParser

  
   /** Gets a String Vector of parameter names.
     * @returns a Vector of String. */
   public Vector getParameters()
   {  char[] name_separators={'=', ' ', '\t'};
      SipParser par=new SipParser(value);
      //par.skipString(); // skip the auth_scheme
      par.skipWSPCRLF();
      Vector names=new Vector();
      while (par.hasMore())
      {  String name=par.getWord(name_separators);
         names.addElement(name);
         par.goToCommaHeaderSeparator().skipChar().skipWSPCRLF();
      }
      return names;
   }
View Full Code Here

Examples of org.zoolu.sip.provider.SipParser

     * <br> It extends the NameAddressHeader.getNameAddress() method, by removing
     * eventual EndPointHeader field parameters (e.g. 'tag' param) from the returnerd NameAddress.
     * @return the end point NameAddress or null if NameAddress does not exist
     * (that leads to the wildcard in case of ContactHeader) */
   public NameAddress getNameAddress()
   {  NameAddress naddr=(new SipParser(value)).getNameAddress();
      // patch for removing eventual 'tag' or other EndPointHeader parameters from NameAddress
      SipURL url=naddr.getAddress();
      for (int i=0; i< ENDPOINT_PARAMS.length; i++)
      {  if (url.hasParameter(ENDPOINT_PARAMS[i]))
         {  url.removeParameter(ENDPOINT_PARAMS[i]);
View Full Code Here

Examples of org.zoolu.sip.provider.SipParser

   super(hd);
   }

   /** Gets NameAddress of NameAddressHeader (Returns null if NameAddress does not exist - i.e. wildcard ContactHeader) */
   public NameAddress getNameAddress()
   {  NameAddress naddr=(new SipParser(value)).getNameAddress();
      return naddr;
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.