public void send(ByteBuffer data) throws Exception { if(conn == null) throw new IllegalStateException("connection to server " + remote_addr + " doesn't exist (has start() been called?)"); conn.send(data); }
public void send(byte[] data, int offset, int length) throws Exception { if(conn == null) throw new IllegalStateException("connection to server " + remote_addr + " doesn't exist (has start() been called?)"); conn.send(data, offset, length); }
public void send(ByteBuffer buf) throws Exception { if(buf == null) return; int offset=buf.hasArray()? buf.arrayOffset() + buf.position() : buf.position(), len=buf.remaining(); if(!buf.isDirect()) send(buf.array(), offset, len); else { // by default use a copy; but of course implementers of Receiver can override this byte[] tmp=new byte[len]; buf.get(tmp, 0, len); send(tmp, 0, len); // will get copied again if send-queues are enabled } }
public void send(byte[] data, int offset, int length) throws Exception { if(conn == null) throw new IllegalStateException("connection to server " + remote_addr + " doesn't exist (has start() been called?)"); conn.send(data, offset, length); }
public void send(ByteBuffer data) throws Exception { if(conn == null) throw new IllegalStateException("connection to server " + remote_addr + " doesn't exist (has start() been called?)"); conn.send(data); }
public void send(ByteBuffer buf) throws Exception { if(buf == null) return; int offset=buf.hasArray()? buf.arrayOffset() + buf.position() : buf.position(), len=buf.remaining(); if(!buf.isDirect()) send(buf.array(), offset, len); else { // by default use a copy; but of course implementers of Receiver can override this byte[] tmp=new byte[len]; buf.get(tmp, 0, len); send(tmp, 0, len); // will get copied again if send-queues are enabled } }
connection.send(message);
connection.send(new GenericMessage<String>("Hello, world!")); assertTrue(latch.await(10, TimeUnit.SECONDS)); assertEquals("Hello, world!", new String((byte[]) messages.get(0).getPayload()));
connection.send(new GenericMessage<>("You took too long to send me data, sorry")); connection.close(); return null;