use of com.hazelcast.client.impl.protocol.util.ClientMessageEncoder in project hazelcast by hazelcast.
the class UnifiedProtocolEncoder method initChannelForClient.
private void initChannelForClient() {
channel.options().setOption(SO_SNDBUF, clientSndBuf());
channel.outboundPipeline().replace(this, new ClientMessageEncoder());
}
use of com.hazelcast.client.impl.protocol.util.ClientMessageEncoder in project hazelcast by hazelcast.
the class ClientPlainChannelInitializer method initChannel.
@Override
public void initChannel(Channel channel) {
channel.options().setOption(SO_SNDBUF, KILO_BYTE * socketOptions.getBufferSize()).setOption(SO_RCVBUF, KILO_BYTE * socketOptions.getBufferSize()).setOption(SO_REUSEADDR, socketOptions.isReuseAddress()).setOption(SO_KEEPALIVE, socketOptions.isKeepAlive()).setOption(SO_LINGER, socketOptions.getLingerSeconds()).setOption(SO_TIMEOUT, 0).setOption(TCP_NODELAY, socketOptions.isTcpNoDelay()).setOption(DIRECT_BUF, directBuffer);
final TcpClientConnection connection = (TcpClientConnection) channel.attributeMap().get(TcpClientConnection.class);
ClientMessageDecoder decoder = new ClientMessageDecoder(connection, connection::handleClientMessage, null);
channel.inboundPipeline().addLast(decoder);
channel.outboundPipeline().addLast(new ClientMessageEncoder());
// before a client sends any data, it first needs to send the protocol.
// so the protocol encoder is actually the last handler in the outbound pipeline.
channel.outboundPipeline().addLast(new ClientProtocolEncoder());
}
use of com.hazelcast.client.impl.protocol.util.ClientMessageEncoder in project hazelcast by hazelcast.
the class ClientChannelInitializer method initChannel.
@Override
public void initChannel(Channel channel) {
ServerConnection connection = (TcpServerConnection) channel.attributeMap().get(ServerConnection.class);
SingleProtocolEncoder protocolEncoder = new SingleProtocolEncoder(new ClientMessageEncoder());
SingleProtocolDecoder protocolDecoder = new SingleProtocolDecoder(CLIENT, new ClientMessageDecoder(connection, serverContext.getClientEngine(), serverContext.properties()), protocolEncoder);
channel.outboundPipeline().addLast(protocolEncoder);
channel.inboundPipeline().addLast(protocolDecoder);
}
Aggregations