use of com.hazelcast.internal.nio.ascii.TextEncoder 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);
}
use of com.hazelcast.internal.nio.ascii.TextEncoder in project hazelcast by hazelcast.
the class UnifiedProtocolEncoder method initChannelForText.
private void initChannelForText() {
channel.options().setOption(SO_SNDBUF, clientSndBuf());
TextEncoder encoder = (TextEncoder) channel.attributeMap().remove(TEXT_ENCODER);
channel.outboundPipeline().replace(this, encoder);
}
Aggregations