Java Examples for io.netty.handler.codec.string.StringDecoder
The following java examples will help you to understand the usage of io.netty.handler.codec.string.StringDecoder. These source code samples are taken from different open source projects.
Example 1
| Project: NettyGameServer-master File: ProtoClientChannleInitializer.java View source code |
@Override
protected void initChannel(NioSocketChannel nioSocketChannel) throws Exception {
short maxLength = Short.MAX_VALUE;
nioSocketChannel.pipeline().addLast(new LengthFieldBasedFrameDecoder(maxLength, 0, 4));
nioSocketChannel.pipeline().addLast(new StringDecoder());
// nioSocketChannel.pipeline().addLast(new StringEncoder());
nioSocketChannel.pipeline().addLast(new ProtoClientHandler());
}Example 2
| Project: netty-cookbook-master File: SimpleTcpServer.java View source code |
protected void start() {
EventLoopGroup parentGroup = new NioEventLoopGroup(1);
EventLoopGroup childGroup = new NioEventLoopGroup();
try {
ServerBootstrap b = new ServerBootstrap();
b.group(parentGroup, childGroup).channel(NioServerSocketChannel.class).handler(new LoggingHandler(LogLevel.INFO)).childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
p.addLast(new StringDecoder(CharsetUtil.UTF_8));
p.addLast(new StringEncoder(CharsetUtil.UTF_8));
p.addLast(channelHandler);
}
});
ChannelFuture f;
if ("*".equals(host)) {
System.out.println("bind at *:" + port);
f = b.bind(port).sync();
} else {
System.out.println("bind at " + host + ":" + port);
f = b.bind(host, port).sync();
}
Channel channel = f.channel();
channel.closeFuture().sync();
} catch (Exception e) {
e.printStackTrace();
} finally {
parentGroup.shutdownGracefully();
childGroup.shutdownGracefully();
}
}Example 3
| Project: gruffalo-master File: GraphiteClientPool.java View source code |
private void initClients(final String[] hosts, final EventLoopGroup eventLoopGroup, final StringDecoder decoder, final StringEncoder encoder, final Throttler throttler, final int inFlightBatchesHighThreshold, final MetricFactory metricFactory) {
for (int i = 0; i < hosts.length; i++) {
final String[] hostAndPort = hosts[i].split(":");
final String host = hostAndPort[0];
final int port = Integer.parseInt(hostAndPort[1]);
final NettyGraphiteClient client = new NettyGraphiteClient(throttler, inFlightBatchesHighThreshold, metricFactory, hosts[i]);
pool[i] = client;
final ChannelHandler graphiteChannelHandler = new GraphiteChannelInboundHandler(client, hosts[i], throttler);
final GraphiteClientChannelInitializer channelInitializer = new GraphiteClientChannelInitializer(host, port, eventLoopGroup, decoder, encoder, graphiteChannelHandler);
client.setChannelInitializer(channelInitializer);
}
}Example 4
| Project: JibbrJabbr-master File: ReplIntegrationTest.java View source code |
@Override
protected void initChannel(NioSocketChannel ch) throws Exception {
ch.pipeline().addLast(new StringEncoder(US_ASCII)).addLast(new StringDecoder(US_ASCII)).addLast(new SimpleChannelInboundHandler<String>() {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
failure.set(cause);
ctx.close();
latch.countDown();
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
if (msg.equals(response.substring(0, msg.length()))) {
response.delete(0, msg.length());
}
if (response.length() == 0) {
ctx.close();
latch.countDown();
}
}
});
}Example 5
| Project: netty-master File: UDTClientServerConnectionTest.java View source code |
@Override
protected void initChannel(final UdtChannel ch) throws Exception {
final ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
pipeline.addLast("decoder", new StringDecoder(CharsetUtil.UTF_8));
pipeline.addLast("encoder", new StringEncoder(CharsetUtil.UTF_8));
pipeline.addLast("handler", new ClientHandler());
}Example 6
| Project: netty-storm-master File: NettySpoutServerInitializer.java View source code |
@Override
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
// Add SSL handler first to encrypt and decrypt everything.
// In this example, we use a bogus certificate in the server side
// and accept any invalid certificates in the client side.
// You will need something more complicated to identify both
// and server in the real world.
pipeline.addLast(sslCtx.newHandler(ch.alloc()));
// On top of the SSL handler, add the text line codec.
pipeline.addLast(new DelimiterBasedFrameDecoder(8 * 8192, Delimiters.lineDelimiter()));
pipeline.addLast(new StringDecoder());
pipeline.addLast(new StringEncoder());
// and then business logic.
pipeline.addLast(new NettySpoutServerHandler(spout));
}Example 7
| Project: netty-study-master File: HeartBeatsClient.java View source code |
public void connect(int port, String host) throws Exception {
EventLoopGroup group = new NioEventLoopGroup();
boot = new Bootstrap();
boot.group(group).channel(NioSocketChannel.class).handler(new LoggingHandler(LogLevel.INFO));
final ConnectionWatchdog watchdog = new ConnectionWatchdog(boot, timer, port, host, true) {
public ChannelHandler[] handlers() {
return new ChannelHandler[] { this, new IdleStateHandler(0, 4, 0, TimeUnit.SECONDS), idleStateTrigger, new StringDecoder(), new StringEncoder(), new HeartBeatClientHandler() };
}
};
ChannelFuture future;
//进行连接
try {
synchronized (boot) {
boot.handler(new ChannelInitializer<Channel>() {
//�始化channel
@Override
protected void initChannel(Channel ch) throws Exception {
ch.pipeline().addLast(watchdog.handlers());
}
});
future = boot.connect(host, port);
}
// 以下代ç ?在synchronizedå?Œæ¥å?—外é?¢æ˜¯å®‰å…¨çš„
future.sync();
} catch (Throwable t) {
throw new Exception("connects to fails", t);
}
}Example 8
| Project: netty4.0.27Learn-master File: UDTClientServerConnectionTest.java View source code |
@Override
protected void initChannel(final UdtChannel ch) throws Exception {
final ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
pipeline.addLast("decoder", new StringDecoder(CharsetUtil.UTF_8));
pipeline.addLast("encoder", new StringEncoder(CharsetUtil.UTF_8));
pipeline.addLast("handler", new ClientHandler());
}Example 9
| Project: netty4study-master File: UDTClientServerConnectionTest.java View source code |
@Override
protected void initChannel(final UdtChannel ch) throws Exception {
final ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
pipeline.addLast("decoder", new StringDecoder(CharsetUtil.UTF_8));
pipeline.addLast("encoder", new StringEncoder(CharsetUtil.UTF_8));
pipeline.addLast("handler", new ClientHandler());
}Example 10
| Project: moco-master File: ShutdownMocoRunnerWatcher.java View source code |
public void startMonitor() {
int actualPort = server.start(this.shutdownPort.or(0), new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(final SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("decoder", new StringDecoder());
pipeline.addLast("handler", new ShutdownHandler());
}
});
this.port = actualPort;
logger.info("Shutdown port is {}", actualPort);
}Example 11
| Project: MoparScape-master File: HandshakeDecoder.java View source code |
@Override
public void inboundBufferUpdated(ChannelHandlerContext ctx, ByteBuf buf) throws IOException {
if (!buf.isReadable())
return;
int service = buf.readUnsignedByte();
ByteBuf additionalBuf = null;
if (buf.isReadable()) {
additionalBuf = buf.readBytes(buf.readableBytes());
}
ChannelPipeline pipeline = ctx.pipeline();
pipeline.remove(HandshakeDecoder.class);
switch(service) {
case HandshakeMessage.SERVICE_LOGIN:
pipeline.addFirst(new LoginEncoder(), new LoginDecoder());
break;
case HandshakeMessage.SERVICE_UPDATE:
pipeline.addFirst(new FileResponseEncoder(), new UpdateStatusMessageEncoder(), new XorEncoder(), new UpdateDecoder());
break;
case HandshakeMessage.SERVICE_JAGGRAB:
pipeline.addFirst(// Dummy encoder here because it wasn't working for some reason without it
new JaggrabEncoder(), new DelimiterBasedFrameDecoder(1024, Delimiters.lineDelimiter()), new StringDecoder(StandardCharsets.US_ASCII), new JaggrabDecoder());
break;
case HandshakeMessage.SERVICE_REGISTER_PERSONAL_DETAILS:
case HandshakeMessage.SERVICE_REGISTER_USERNAME:
case HandshakeMessage.SERVICE_REGISTER_COMMIT:
pipeline.addFirst(new RegisterEncoder(), new RegisterDecoder(service));
break;
case HandshakeMessage.SERVICE_AUTO_LOGIN:
pipeline.addFirst(new LoginEncoder(), new AutoLoginDecoder());
break;
case HandshakeMessage.SERVICE_WORLD_LIST:
pipeline.addFirst(new WorldListEncoder(), new WorldListDecoder());
break;
default:
throw new IOException("Invalid service id: " + service + ".");
}
ctx.nextInboundMessageBuffer().add(new HandshakeMessage(service));
ctx.fireInboundBufferUpdated();
if (additionalBuf != null) {
ChannelHandlerContext head = ctx.pipeline().firstContext();
head.nextInboundByteBuffer().writeBytes(additionalBuf);
head.fireInboundBufferUpdated();
}
}Example 12
| Project: netty-book-master File: EchoServer.java View source code |
public void bind(int port) throws Exception {
// �置�务端的NIO线程组
EventLoopGroup bossGroup = new NioEventLoopGroup();
EventLoopGroup workerGroup = new NioEventLoopGroup();
try {
ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).option(ChannelOption.SO_BACKLOG, 100).handler(new LoggingHandler(LogLevel.INFO)).childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel ch) throws Exception {
ByteBuf delimiter = Unpooled.copiedBuffer("$_".getBytes());
ch.pipeline().addLast(new DelimiterBasedFrameDecoder(1024, delimiter));
ch.pipeline().addLast(new StringDecoder());
ch.pipeline().addLast(new EchoServerHandler());
}
});
// 绑定端å?£ï¼Œå?Œæ¥ç‰å¾…æˆ?功
ChannelFuture f = b.bind(port).sync();
// ç‰å¾…æœ?务端监å?¬ç«¯å?£å…³é—
f.channel().closeFuture().sync();
} finally {
// ä¼˜é›…é€€å‡ºï¼Œé‡Šæ”¾çº¿ç¨‹æ± èµ„æº?
bossGroup.shutdownGracefully();
workerGroup.shutdownGracefully();
}
}Example 13
| Project: nettybook2-master File: SecureChatServerInitializer.java View source code |
@Override
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
// Add SSL handler first to encrypt and decrypt everything.
// In this example, we use a bogus certificate in the server side
// and accept any invalid certificates in the client side.
// You will need something more complicated to identify both
// and server in the real world.
//
// Read SecureChatSslContextFactory
// if you need client certificate authentication.
SSLEngine engine = null;
if (SSLMODE.CA.toString().equals(tlsMode)) {
engine = SecureChatSslContextFactory.getServerContext(tlsMode, System.getProperty("user.dir") + "/src/com/phei/netty/ssl/conf/client/sChat.jks", null).createSSLEngine();
} else if (SSLMODE.CSA.toString().equals(tlsMode)) {
engine = SecureChatSslContextFactory.getServerContext(tlsMode, System.getProperty("user.dir") + "/src/com/phei/netty/ssl/conf/twoway/sChat.jks", System.getProperty("user.dir") + "/src/com/phei/netty/ssl/conf/twoway/sChat.jks").createSSLEngine();
// engine = SecureChatSslContextFactory
// .getServerContext(
// tlsMode,
// System.getProperty("user.dir")
// + "/src/com/phei/netty/ssl/conf/client/sChat.jks",
// System.getProperty("user.dir")
// + "/src/com/phei/netty/ssl/conf/client/sChat.jks")
// .createSSLEngine();
} else {
System.err.println("ERROR : " + tlsMode);
System.exit(-1);
}
engine.setUseClientMode(false);
// Client auth
if (SSLMODE.CSA.toString().equals(tlsMode))
engine.setNeedClientAuth(true);
pipeline.addLast("ssl", new SslHandler(engine));
// On top of the SSL handler, add the text line codec.
pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
pipeline.addLast("decoder", new StringDecoder());
pipeline.addLast("encoder", new StringEncoder());
// and then business logic.
pipeline.addLast("handler", new SecureChatServerHandler());
}Example 14
| Project: WaarpExec-master File: LocalExecSslServerInitializer.java View source code |
@Override
public void initChannel(SocketChannel ch) throws Exception {
// Create a default pipeline implementation.
ChannelPipeline pipeline = ch.pipeline();
// Add SSL as first element in the pipeline
SslHandler sslhandler = waarpSslContextFactory.initInitializer(true, waarpSslContextFactory.needClientAuthentication());
pipeline.addLast("ssl", sslhandler);
// Add the text line codec combination first,
pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
pipeline.addLast(eventExecutorGroup, "decoder", new StringDecoder());
pipeline.addLast(eventExecutorGroup, "encoder", new StringEncoder());
// and then business logic.
// Could change it with a new fixed delay if necessary at construction
pipeline.addLast(eventExecutorGroup, "handler", new LocalExecSslServerHandler(this, delay));
}Example 15
| Project: BrowserPush-master File: EventSource.java View source code |
@Override
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
//Lines must be separated by either a U+000D CARRIAGE RETURN U+000A LINE FEED (CRLF) character pair,
//a single U+000A LINE FEED (LF) character,
//or a single U+000D CARRIAGE RETURN (CR) character.
p.addLast(new HttpRequestEncoder(), new DelimiterBasedFrameDecoder(Integer.MAX_VALUE, new ByteBuf[] { Unpooled.wrappedBuffer(new byte[] { '\r', '\n' }), Unpooled.wrappedBuffer(new byte[] { '\n' }), Unpooled.wrappedBuffer(new byte[] { '\r' }) }), new StringDecoder(CharsetUtil.UTF_8), handler);
}Example 16
| Project: camel-master File: NettyCustomPipelineFactorySynchTest.java View source code |
@Override
protected void initChannel(Channel ch) throws Exception {
ChannelPipeline channelPipeline = ch.pipeline();
clientInvoked = true;
channelPipeline.addLast("decoder-DELIM", new DelimiterBasedFrameDecoder(maxLineSize, true, Delimiters.lineDelimiter()));
channelPipeline.addLast("decoder-SD", new StringDecoder(CharsetUtil.UTF_8));
channelPipeline.addLast("encoder-SD", new StringEncoder(CharsetUtil.UTF_8));
channelPipeline.addLast("handler", new ClientChannelHandler(producer));
}Example 17
| Project: hasor-master File: TelnetClient.java View source code |
public void initChannel(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
pipeline.addLast(new StringDecoder());
pipeline.addLast(new StringEncoder());
pipeline.addLast(new TelnetClientHandler(closeFuture, atomicBoolean));
}Example 18
| Project: reactive-ipc-jvm-master File: CodecSample.java View source code |
@Override
protected void initChannel(Channel channel) throws Exception {
int bufferSize = 1024;
ChannelConfig config = channel.config();
config.setOption(ChannelOption.SO_RCVBUF, bufferSize);
config.setOption(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(bufferSize));
channel.pipeline().addFirst(new LineBasedFrameDecoder(256), new StringDecoder(CharsetUtil.UTF_8), new StringEncoder(CharsetUtil.UTF_8));
}Example 19
| Project: flink-master File: NettyClientServerSslTest.java View source code |
/**
* Verify valid ssl configuration and connection
*
*/
@Test
public void testValidSslConnection() throws Exception {
NettyProtocol protocol = new NettyProtocol() {
@Override
public ChannelHandler[] getServerChannelHandlers() {
return new ChannelHandler[0];
}
@Override
public ChannelHandler[] getClientChannelHandlers() {
return new ChannelHandler[0];
}
};
NettyConfig nettyConfig = new NettyConfig(InetAddress.getLoopbackAddress(), NetUtils.getAvailablePort(), NettyTestUtil.DEFAULT_SEGMENT_SIZE, 1, createSslConfig());
NettyTestUtil.NettyServerAndClient serverAndClient = NettyTestUtil.initServerAndClient(protocol, nettyConfig);
Channel ch = NettyTestUtil.connect(serverAndClient);
// should be able to send text data
ch.pipeline().addLast(new StringDecoder()).addLast(new StringEncoder());
assertTrue(ch.writeAndFlush("test").await().isSuccess());
NettyTestUtil.shutdown(serverAndClient);
}Example 20
| Project: johanna-master File: JohannahServer.java View source code |
@Override
public void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast("framer", new DelimiterBasedFrameDecoder(1024 * 1024 * 1024, Delimiters.lineDelimiter()));
ch.pipeline().addLast("decoder", new StringDecoder(Charset.forName("iso-8859-1")));
ch.pipeline().addLast("encoder", new StringEncoder(Charset.forName("iso-8859-1")));
ch.pipeline().addLast(executorGroup, new JohannaServerHandler(store));
}Example 21
| Project: onos-master File: DefaultTl1Controller.java View source code |
@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
socketChannel.pipeline().addLast(new DelimiterBasedFrameDecoder(8192, DELIMITER));
socketChannel.pipeline().addLast("stringDecoder", new StringDecoder(CharsetUtil.UTF_8));
// TODO
//socketChannel.pipeline().addLast(new Tl1Decoder());
socketChannel.pipeline().addLast(new Tl1InboundHandler());
}Example 22
| Project: dcache-master File: NettyLineBasedDoor.java View source code |
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
ChannelPipeline pipeline = ctx.pipeline();
String self = ctx.name();
if (expectProxyProtocol) {
pipeline.addBefore("door", "haproxy", new HAProxyMessageDecoder());
}
// Decoders
pipeline.addBefore(self, "frameDecoder", new LineBasedFrameDecoder(65536));
pipeline.addBefore(self, "stringDecoder", new StringDecoder(charset));
// Encoder
pipeline.addBefore(self, "lineEncoder", new LineEncoder(lineSeparator, charset));
pipeline.addBefore(self, "logger", new LoggingHandler());
}Example 23
| Project: JgFramework-master File: ServiceConnector.java View source code |
@Override
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
if (!Boot.getDebug()) {
pipeline.addLast(new IdleStateHandler(heartbeatTime * 2, 0, heartbeatTime, TimeUnit.SECONDS));
}
pipeline.addLast(new StringEncoder(Boot.getCharset()));
pipeline.addLast(new StringDecoder(Boot.getCharset()));
pipeline.addLast(new MessageEncode());
pipeline.addLast(new MessageDecode());
pipeline.addLast(new ServiceChannelHandler());
}Example 24
| Project: usc-master File: UscPluginTest.java View source code |
@Override
public void initChannel(LocalChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
p.addLast(new LoggingHandler("UscPluginTest client", LogLevel.TRACE));
// Decoders
p.addLast("frameDecoder", new DelimiterBasedFrameDecoder(80, false, Delimiters.lineDelimiter()));
p.addLast("stringDecoder", new StringDecoder(CharsetUtil.UTF_8));
// Encoder
p.addLast("stringEncoder", new StringEncoder(CharsetUtil.UTF_8));
}Example 25
| Project: wildfly-swarm-master File: Server.java View source code |
private void setupPipeline(final ChannelPipeline pipeline) {
pipeline.addLast(NAME_CHANNEL_HANDLER_FRAME_DECODER, new DelimiterBasedFrameDecoder(2000, Delimiters.lineDelimiter()));
pipeline.addLast(NAME_CHANNEL_HANDLER_STRING_DECODER, new StringDecoder(WireProtocol.CHARSET));
pipeline.addLast(NAME_CHANNEL_HANDLER_COMMAND, new StringCommandHandler());
}Example 26
| Project: juicebot-master File: Bot.java View source code |
@Override
protected void initChannel(OioSocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
// SSL Support
if (useSSL) {
SSLEngine engine = SSLContext.getDefault().createSSLEngine();
engine.setUseClientMode(true);
pipeline.addLast("ssl", new SslHandler(engine));
}
// Decoders
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1000));
pipeline.addLast("stringDecoder", new StringDecoder(CharsetUtil.UTF_8));
// Encoder
pipeline.addLast("stringEncoder", new StringEncoder(CharsetUtil.UTF_8));
// Handlers
pipeline.addLast("botHandler", new ClientHandlerAdapter(Bot.this));
}Example 27
| Project: arquillian-daemon-master File: NettyServer.java View source code |
@Override
public void inboundBufferUpdated(final ChannelHandlerContext ctx, final ByteBuf in) throws Exception {
// We require at least three bytes to determine the action taken
if (in.readableBytes() < 3) {
return;
}
// Get the pipeline so we can dynamically adjust it and fire events
final ChannelPipeline pipeline = ctx.pipeline();
// Pull out the magic header
int readerIndex = in.readerIndex();
final int magic1 = in.getUnsignedByte(readerIndex);
final int magic2 = in.getUnsignedByte(readerIndex + 1);
final int magic3 = in.getUnsignedByte(readerIndex + 2);
// String-based Command?
if (this.isStringCommand(magic1, magic2, magic3)) {
// Write a line break into the buffer so we mark the frame
in.writeBytes(Delimiters.lineDelimiter()[0]);
// Adjust the pipeline such that we use the command handler
pipeline.addLast(NAME_CHANNEL_HANDLER_FRAME_DECODER, new DelimiterBasedFrameDecoder(2000, Delimiters.lineDelimiter()));
pipeline.addLast(NAME_CHANNEL_HANDLER_STRING_DECODER, new StringDecoder(Charset.forName(WireProtocol.CHARSET)));
pipeline.addLast(NAME_CHANNEL_HANDLER_COMMAND, new StringCommandHandler());
pipeline.remove(NAME_CHANNEL_HANDLER_ACTION_CONTROLLER);
pipeline.remove(NAME_CHANNEL_HANDLER_EOF);
} else // Deploy command?
if (this.isDeployCommand(magic1, magic2, magic3)) {
// Set the reader index so we strip out the command portion, leaving only the bytes containing the
// archive (the frame decoder will strip off the EOF delimiter)
in.readerIndex(in.readerIndex() + WireProtocol.COMMAND_DEPLOY_PREFIX.length());
// Adjust the pipeline such that we use the deploy handler only
pipeline.addLast(NAME_CHANNEL_HANDLER_DEPLOY_HANDLER, new DeployHandlerAdapter());
pipeline.remove(NAME_CHANNEL_HANDLER_ACTION_CONTROLLER);
pipeline.remove(NAME_CHANNEL_HANDLER_EOF);
} else {
// Unknown command/protocol
NettyServer.sendResponse(ctx, ctx.nextOutboundByteBuffer(), WireProtocol.RESPONSE_ERROR_PREFIX + "Unsupported Command");
in.clear();
ctx.close();
return;
}
// Write the bytes to the next inbound buffer and re-fire so the updated handlers in the pipeline can have a
// go at it
final ByteBuf nextInboundByteBuffer = ctx.nextInboundByteBuffer();
nextInboundByteBuffer.writeBytes(in);
pipeline.fireInboundBufferUpdated();
}Example 28
| Project: mpush-master File: AdminServer.java View source code |
@Override
protected ChannelHandler getDecoder() {
return new StringDecoder();
}