Search in sources :

Example 1 with ClientMessageEncoder

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());
}
Also used : ClientMessageEncoder(com.hazelcast.client.impl.protocol.util.ClientMessageEncoder)

Example 2 with 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());
}
Also used : ClientMessageDecoder(com.hazelcast.client.impl.protocol.util.ClientMessageDecoder) ClientMessageEncoder(com.hazelcast.client.impl.protocol.util.ClientMessageEncoder)

Example 3 with ClientMessageEncoder

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);
}
Also used : ClientMessageDecoder(com.hazelcast.client.impl.protocol.util.ClientMessageDecoder) ServerConnection(com.hazelcast.internal.server.ServerConnection) ClientMessageEncoder(com.hazelcast.client.impl.protocol.util.ClientMessageEncoder)

Aggregations

ClientMessageEncoder (com.hazelcast.client.impl.protocol.util.ClientMessageEncoder)3 ClientMessageDecoder (com.hazelcast.client.impl.protocol.util.ClientMessageDecoder)2 ServerConnection (com.hazelcast.internal.server.ServerConnection)1