Search in sources :

Example 1 with ClientMessageDecoder

use of com.hazelcast.client.impl.protocol.util.ClientMessageDecoder in project hazelcast by hazelcast.

the class UnifiedProtocolDecoder method initChannelForClient.

private void initChannelForClient() {
    protocolEncoder.signalEncoderCanReplace();
    channel.options().setOption(SO_RCVBUF, clientRcvBuf()).setOption(DIRECT_BUF, false);
    ServerConnection connection = (TcpServerConnection) channel.attributeMap().get(ServerConnection.class);
    channel.inboundPipeline().replace(this, new ClientMessageDecoder(connection, serverContext.getClientEngine(), props));
}
Also used : ClientMessageDecoder(com.hazelcast.client.impl.protocol.util.ClientMessageDecoder) ServerConnection(com.hazelcast.internal.server.ServerConnection)

Example 2 with ClientMessageDecoder

use of com.hazelcast.client.impl.protocol.util.ClientMessageDecoder 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 ClientMessageDecoder

use of com.hazelcast.client.impl.protocol.util.ClientMessageDecoder 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

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