Package org.cipango.sip

Examples of org.cipango.sip.SipParser$EventHandler


  }
 
  public static SipMessage getMessage(String msg) throws Exception
  {
    EventHandler handler = new EventHandler();
    SipParser parser = new SipParser(new ByteArrayBuffer(msg.getBytes()), handler);
    parser.parse();
    return handler.getMessage();
  }
View Full Code Here


    int read;
    while ((read = is.read(buffer)) != -1)
    {
      os.write(buffer, 0, read);
    }
    SipParser parser = new SipParser(new ByteArrayBuffer(os.toByteArray()), handler);
    parser.parse();
   
    SipMessage message = handler.getMessage();
    String toString = message.toString();
    System.out.println(message);
   
View Full Code Here

    System.arraycopy(p.getData(), 0, b, 0, length);
   
    Buffer buffer = new ByteArrayBuffer(b);
   
    EventHandler handler = new EventHandler();
    SipParser parser = new SipParser(buffer, handler);
   
    try
    {
      parser.parse();
     
      SipMessage message = handler.getMessage();
      message.setConnection(new UdpConnection(p.getAddress(), p.getPort()));
     
      /*
 
View Full Code Here

    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

TOP

Related Classes of org.cipango.sip.SipParser$EventHandler

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.