@Override public MessageBuffer<ByteBuf> writeStrings(String... messages) { ByteBuf strMultiBuf = NettyUtils.writeStrings(messages); buffer.writeBytes(strMultiBuf); strMultiBuf.release(); return this; }
/** * Read a socket address from a buffer. The socket address will be provided as two strings * containing host and port. * * @param buffer The buffer containing the host and port as string. * @return The InetSocketAddress object created from host and port or null in case the strings are * not there. */ public static InetSocketAddress readSocketAddress(ByteBuf buffer) { String remoteHost = NettyUtils.readString(buffer); int remotePort = 0; if (buffer.readableBytes() >= 4) { remotePort = buffer.readInt(); } else { return null; } InetSocketAddress remoteAddress = null; if (null != remoteHost) { remoteAddress = new InetSocketAddress(remoteHost, remotePort); } return remoteAddress; }
@Override public <V> MessageBuffer<ByteBuf> writeObject(Transform<V, ByteBuf> converter, V object) { ByteBuf objBuf = NettyUtils.writeObject(converter, object); buffer.writeBytes(objBuf); return this; }
@Override public MessageBuffer<ByteBuf> writeString(String message) { ByteBuf strBuf = NettyUtils.writeString(message); buffer.writeBytes(strBuf); return this; }
@Override public <V> V readObject(Transform<ByteBuf, V> converter) { return NettyUtils.readObject(buffer, converter); }
@Override public String[] readStrings(int numOfStrings) { return NettyUtils.readStrings(buffer, numOfStrings); }
@Override public String readString() { return NettyUtils.readString(buffer); }