protected void newData( NioEndpoint p, SocketChannel c, ByteBuffer shared, int size ) { // Note: if ever desirable, it would be possible to accumulate // data per source channel and only 'finalize' it when // asked for more envelopes then were ready. I just don't // think it will be an issue in practice. The busier the // server, the more the buffers will fill before we get to them. // And if the server isn't busy, who cares if we chop things up // smaller... the network is still likely to deliver things in // bulk anyway. // Must copy the shared data before we use it byte[] dataCopy = new byte[size]; System.arraycopy(shared.array(), 0, dataCopy, 0, size); Envelope env = new Envelope( p, dataCopy, true ); addEnvelope( env ); }
protected void newData( DatagramPacket packet ) { // So the tricky part here is figuring out the endpoint and // whether it's new or not. In these UDP schemes, firewalls have // to be ported back to a specific machine so we will consider // the address + port (ie: SocketAddress) the defacto unique // ID. Endpoint p = getEndpoint( packet.getSocketAddress(), true ); // We'll copy the data to trim it. byte[] data = new byte[packet.getLength()]; System.arraycopy(packet.getData(), 0, data, 0, data.length); Envelope env = new Envelope( p, data, false ); addEnvelope( env ); }
protected void newData( NioEndpoint p, SocketChannel c, ByteBuffer shared, int size ) { // Note: if ever desirable, it would be possible to accumulate // data per source channel and only 'finalize' it when // asked for more envelopes then were ready. I just don't // think it will be an issue in practice. The busier the // server, the more the buffers will fill before we get to them. // And if the server isn't busy, who cares if we chop things up // smaller... the network is still likely to deliver things in // bulk anyway. // Must copy the shared data before we use it byte[] dataCopy = new byte[size]; System.arraycopy(shared.array(), 0, dataCopy, 0, size); Envelope env = new Envelope( p, dataCopy, true ); addEnvelope( env ); }
protected void newData( NioEndpoint p, SocketChannel c, ByteBuffer shared, int size ) { // Note: if ever desirable, it would be possible to accumulate // data per source channel and only 'finalize' it when // asked for more envelopes then were ready. I just don't // think it will be an issue in practice. The busier the // server, the more the buffers will fill before we get to them. // And if the server isn't busy, who cares if we chop things up // smaller... the network is still likely to deliver things in // bulk anyway. // Must copy the shared data before we use it byte[] dataCopy = new byte[size]; System.arraycopy(shared.array(), 0, dataCopy, 0, size); Envelope env = new Envelope( p, dataCopy, true ); addEnvelope( env ); }
protected void newData( DatagramPacket packet ) { // So the tricky part here is figuring out the endpoint and // whether it's new or not. In these UDP schemes, firewalls have // to be ported back to a specific machine so we will consider // the address + port (ie: SocketAddress) the defacto unique // ID. Endpoint p = getEndpoint( packet.getSocketAddress(), true ); // We'll copy the data to trim it. byte[] data = new byte[packet.getLength()]; System.arraycopy(packet.getData(), 0, data, 0, data.length); Envelope env = new Envelope( p, data, false ); addEnvelope( env ); }
protected void newData( DatagramPacket packet ) { // So the tricky part here is figuring out the endpoint and // whether it's new or not. In these UDP schemes, firewalls have // to be ported back to a specific machine so we will consider // the address + port (ie: SocketAddress) the defacto unique // ID. Endpoint p = getEndpoint( packet.getSocketAddress(), true ); // We'll copy the data to trim it. byte[] data = new byte[packet.getLength()]; System.arraycopy(packet.getData(), 0, data, 0, data.length); Envelope env = new Envelope( p, data, false ); addEnvelope( env ); }