public void send( ByteBuffer data ) { if( data == null ) { throw new IllegalArgumentException( "Data cannot be null." ); } if( closing ) { throw new KernelException( "Endpoint has been closed:" + socket ); } send( data, true, true ); }
public void broadcast( Filter<? super Endpoint> filter, ByteBuffer data, boolean reliable, boolean copy ) { if( !reliable ) throw new UnsupportedOperationException( "Unreliable send not supported by this kernel." ); if( copy ) { // Copy the data just once byte[] temp = new byte[data.remaining()]; System.arraycopy(data.array(), data.position(), temp, 0, data.remaining()); data = ByteBuffer.wrap(temp); } // Hand it to all of the endpoints that match our routing for( NioEndpoint p : endpoints.values() ) { // Does it match the filter? if( filter != null && !filter.apply(p) ) continue; // Give it the data... but let each endpoint track their // own completion over the shared array of bytes by // duplicating it p.send( data.duplicate(), false, false ); } // Wake up the selector so it can reinitialize its // state accordingly. wakeupSelector(); }
public void close( boolean flushData ) { if( flushData ) { closing = true; // Enqueue a close marker message to let the server // know we should close send( CLOSE_MARKER, false, true ); return; } try { // Note: even though we may be disconnected from the socket.isConnected() // standpoint, it's still safest to tell the kernel so that it can be sure // to stop managing us gracefully. kernel.closeEndpoint(this); } catch( IOException e ) { throw new KernelException( "Error closing endpoint for socket:" + socket, e ); } }
public void send( ByteBuffer data ) { if( data == null ) { throw new IllegalArgumentException( "Data cannot be null." ); } if( closing ) { throw new KernelException( "Endpoint has been closed:" + socket ); } send( data, true, true ); }
public void send( ByteBuffer data ) { if( data == null ) { throw new IllegalArgumentException( "Data cannot be null." ); } if( closing ) { throw new KernelException( "Endpoint has been closed:" + socket ); } send( data, true, true ); }
public void broadcast( Filter<? super Endpoint> filter, ByteBuffer data, boolean reliable, boolean copy ) { if( !reliable ) throw new UnsupportedOperationException( "Unreliable send not supported by this kernel." ); if( copy ) { // Copy the data just once byte[] temp = new byte[data.remaining()]; System.arraycopy(data.array(), data.position(), temp, 0, data.remaining()); data = ByteBuffer.wrap(temp); } // Hand it to all of the endpoints that match our routing for( NioEndpoint p : endpoints.values() ) { // Does it match the filter? if( filter != null && !filter.apply(p) ) continue; // Give it the data... but let each endpoint track their // own completion over the shared array of bytes by // duplicating it p.send( data.duplicate(), false, false ); } // Wake up the selector so it can reinitialize its // state accordingly. wakeupSelector(); }
public void broadcast( Filter<? super Endpoint> filter, ByteBuffer data, boolean reliable, boolean copy ) { if( !reliable ) throw new UnsupportedOperationException( "Unreliable send not supported by this kernel." ); if( copy ) { // Copy the data just once byte[] temp = new byte[data.remaining()]; System.arraycopy(data.array(), data.position(), temp, 0, data.remaining()); data = ByteBuffer.wrap(temp); } // Hand it to all of the endpoints that match our routing for( NioEndpoint p : endpoints.values() ) { // Does it match the filter? if( filter != null && !filter.apply(p) ) continue; // Give it the data... but let each endpoint track their // own completion over the shared array of bytes by // duplicating it p.send( data.duplicate(), false, false ); } // Wake up the selector so it can reinitialize its // state accordingly. wakeupSelector(); }
public void close( boolean flushData ) { if( flushData ) { closing = true; // Enqueue a close marker message to let the server // know we should close send( CLOSE_MARKER, false, true ); return; } try { kernel.closeEndpoint(this); } catch( IOException e ) { throw new KernelException( "Error closing endpoint for socket:" + socket, e ); } }
public void close( boolean flushData ) { if( flushData ) { closing = true; // Enqueue a close marker message to let the server // know we should close send( CLOSE_MARKER, false, true ); return; } try { // Note: even though we may be disconnected from the socket.isConnected() // standpoint, it's still safest to tell the kernel so that it can be sure // to stop managing us gracefully. kernel.closeEndpoint(this); } catch( IOException e ) { throw new KernelException( "Error closing endpoint for socket:" + socket, e ); } }