Examples of FlexBuffer


Examples of etch.util.FlexBuffer

    final InputStream is = inputStream;
    if (is == null)
      throw new IOException( "socket closed" );
   
    // TODO allow setting input buffer size.
    final FlexBuffer buf = new FlexBuffer( new byte[8192] );
   
    try
    {
      while (isStarted())
      {
//        System.out.println( "reading" );
        int n = is.read( buf.getBuf() );
//        System.out.println( "read "+n );
       
        if (n <= 0)
          break;
       
        buf.setLength( n );
        buf.setIndex( 0 );
        fireData( buf );
      }
    }
    catch ( SSLHandshakeException ex )
    {
View Full Code Here

Examples of etch.util.FlexBuffer

       
        buf.flip();
        byte[] bbuf = new byte[buf.remaining()];
        buf.get( bbuf );
       
        FlexBuffer fbuf = new FlexBuffer( bbuf );
        session.sessionData( null, fbuf );
      }
      finally
      {
        if (buf != null)
View Full Code Here

Examples of etch.util.FlexBuffer

    final InputStream is = inputStream;
    if (is == null)
      throw new IOException( "socket closed" );
   
    // TODO allow setting input buffer size.
    final FlexBuffer buf = new FlexBuffer( new byte[8192] );
   
    try
    {
      while (isStarted())
      {
//        System.out.println( "reading" );
        int n = is.read( buf.getBuf() );
//        System.out.println( "read "+n );
       
        if (n <= 0)
          break;
       
        buf.setLength( n );
        buf.setIndex( 0 );
        fireData( buf );
      }
    }
    catch ( SocketException e )
    {
View Full Code Here

Examples of etch.util.FlexBuffer

  @Override
  protected void readSocket() throws Exception
  {
    final DatagramSocket s = checkSocket();
    // TODO allow buffer size to be specified.
    final FlexBuffer buf = new FlexBuffer( new byte[8192] );
    final DatagramPacket p = new DatagramPacket( new byte[0], 0 );
   
    try
    {
      while (isStarted())
      {
        p.setData( buf.getBuf() );
       
        s.receive( p );
       
        buf.setIndex( 0 );
        buf.setLength( p.getLength() );
       
        if (s.isConnected())
          session.sessionPacket( null, buf );
        else
          session.sessionPacket( getWho( p.getAddress(), p.getPort() ), buf );
View Full Code Here

Examples of etch.util.FlexBuffer

    Message msg = new Message( t, vf );
    msg.put( f, value );
//    System.out.println( "msg = "+msg );
   
    BinaryTaggedDataOutput btdo = new BinaryTaggedDataOutput( vf, "none:" );
    FlexBuffer buf = new FlexBuffer();
   
    btdo.writeMessage( msg, buf );
   
    buf.setIndex( 0 );
    byte[] b = buf.getAvailBytes();
//    dump( b );
    assertArrayEquals( expectedBytes, b );
  }
View Full Code Here

Examples of etch.util.FlexBuffer

    }
  }
 
  private byte[] msg2bytes( Message msg, Boolean stringTypeAndField ) throws IOException
  {
    FlexBuffer buf = new FlexBuffer();
   
    URL u = new URL( "none:" );
    if (stringTypeAndField != null)
      u.addTerm( BinaryTaggedDataOutput.STRING_TYPE_AND_FIELD, stringTypeAndField );
   
    BinaryTaggedDataOutput btdo = new BinaryTaggedDataOutput( vf, u.toString() );
    btdo.writeMessage( msg, buf );
    buf.setIndex( 0 );
    return buf.getAvailBytes();
  }
View Full Code Here

Examples of etch.util.FlexBuffer

  {
    Level oldLevel = vf.setLevel( level );
    try
    {
      BinaryTaggedDataInput btdi = new BinaryTaggedDataInput( vf, "none:" );
      return btdi.readMessage( new FlexBuffer( buf ) );
    }
    finally
    {
      vf.setLevel( oldLevel );
    }
View Full Code Here

Examples of etch.util.FlexBuffer

  /** @throws Exception */
  @Test
  public void packet1() throws Exception
  {
    FlexBuffer buf = new FlexBuffer( new byte[]
    { VERSION, 1, 0, NONE } );
   
    session.msg_handled = true;
   
    m.sessionPacket( who, buf );
View Full Code Here

Examples of etch.util.FlexBuffer

  /** @throws Exception */
  @Test
  public void packet2() throws Exception
  {
    FlexBuffer buf = new FlexBuffer( new byte[]
    { VERSION, 1, 0, NONE } );
   
    session.msg_handled = false;
   
    m.sessionPacket( who, buf );
View Full Code Here

Examples of etch.util.FlexBuffer

  /** @throws Exception */
  @Test
  public void packet3() throws Exception
  {
    FlexBuffer buf = new FlexBuffer( new byte[]
    { VERSION, 2, 0, NONE } );
   
    session.msg_handled = true;
   
    m.sessionPacket( who, buf );
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.