use of com.hazelcast.internal.nio.ascii.TextDecoder in project hazelcast by hazelcast.
the class UnifiedProtocolDecoder method initChannelForText.
private void initChannelForText(String protocol, boolean restApi) {
protocolEncoder.signalEncoderCanReplace();
ChannelOptions config = channel.options();
config.setOption(SO_RCVBUF, clientRcvBuf());
ServerConnection connection = (TcpServerConnection) channel.attributeMap().get(ServerConnection.class);
TextEncoder encoder = new TextEncoder(connection);
channel.attributeMap().put(TextEncoder.TEXT_ENCODER, encoder);
TextDecoder decoder = restApi ? new RestApiTextDecoder(connection, encoder, false) : new MemcacheTextDecoder(connection, encoder, false);
decoder.src(newByteBuffer(config.getOption(SO_RCVBUF), config.getOption(DIRECT_BUF)));
// we need to restore whatever is read
decoder.src().put(stringToBytes(protocol));
channel.inboundPipeline().replace(this, decoder);
}
Aggregations