List of usage examples for io.netty.channel ChannelHandlerContext flush
@Override ChannelHandlerContext flush();
From source file:com.example.http.hello.HttpHelloServerHandler.java
License:Apache License
@Override public void channelReadComplete(final ChannelHandlerContext ctx) { log.info("complete[{}, hash: {}]", current, hasher.hashCode()); ctx.flush(); }
From source file:com.friz.owari.network.client.ClientChannelHandler.java
License:Open Source License
@Override public void channelActive(ChannelHandlerContext ctx) { System.out.println("[Client] Channel Connected to: " + ctx.channel().remoteAddress().toString()); ctx.channel().attr(client.getAttr()).set(new SessionContext<Client>(ctx.channel(), client)); ctx.channel().writeAndFlush(new HandshakeEvent(72)); ctx.flush(); }
From source file:com.github.binlee1990.transformers.netty.examples.echo.EchoServerHandler.java
License:Apache License
@Override public void channelReadComplete(ChannelHandlerContext ctx) { logger.info("-------------------end------------------"); ctx.flush(); }
From source file:com.github.herong.rpc.netty.protobuf.demo3.Demo3ProtobufClientHandler.java
License:Apache License
@Override public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { logger.info("channelReadComplete {}", ctx.channel()); ctx.flush(); }
From source file:com.github.nettybook.ch0.LoggingHandler.java
License:Apache License
@Override public void flush(ChannelHandlerContext ctx) throws Exception { if (logger.isEnabled(internalLevel)) { logger.log(internalLevel, format(ctx, "FLUSH")); }/*from w ww . j av a 2 s. c o m*/ ctx.flush(); }
From source file:com.github.nettybook.ch4.EchoClientHandler2.java
License:Apache License
@Override public void channelActive(ChannelHandlerContext ctx) { String sendMessage = "Hello netty"; ByteBuf messageBuffer = Unpooled.buffer(); messageBuffer.writeBytes(sendMessage.getBytes()); StringBuilder builder = new StringBuilder(); builder.append(" ? ["); builder.append(sendMessage);/* w w w. j a v a 2s . c om*/ builder.append("]"); System.out.println(builder.toString()); ctx.write(messageBuffer); ctx.flush(); }
From source file:com.github.nettybook.ch7.junit.TelnetServerHandlerNetty.java
License:Apache License
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { // Send greeting for a new connection. ctx.write("Welcome to " + InetAddress.getLocalHost().getHostName() + "!\r\n"); ctx.write("It is " + new Date() + " now.\r\n"); ctx.flush(); System.out.println(InetAddress.getLocalHost().getHostName() + " channelActive "); }
From source file:com.github.nettybook.ch7.junit.TelnetServerHandlerV3.java
License:Apache License
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { // Send greeting for a new connection. ctx.write(ResponseGenerator.makeHello()); ctx.flush(); }
From source file:com.github.nettybook.ch8.TelnetServerHandler.java
License:Apache License
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { ctx.write(InetAddress.getLocalHost().getHostName() + " ? ? !\r\n"); ctx.write(" ? " + new Date() + " .\r\n"); ctx.flush(); }
From source file:com.goodgamenow.source.serverquery.MasterQueryHandler.java
License:Open Source License
/** * Decodes a master server response datagram packet into a list of * game server addresses./* www.j ava 2s. c o m*/ * * @param ctx channel handler context * @param msg master server response packet * @exception UnsupportedEncodingException */ @Override protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws UnsupportedEncodingException { ByteBuf buf = msg.content(); // sanity check int ADDR_WIDTH = 6; assert (buf.readableBytes() % ADDR_WIDTH) == 0 : "Master response byte count is not 6 byte aligned."; // decode response header String header = decodeIpAddress(buf); assert EXPECTED_HEADER_STRING.equals(header); while (buf.isReadable(ADDR_WIDTH)) { lastAddress = decodeIpAddress(buf); // A last address of 0.0.0.0:0 denotes the end of transmission. if (DEFAULT_IP.equals(lastAddress)) { ctx.flush(); ctx.close(); finishTime = System.currentTimeMillis(); return; } if (parentContext != null) { InetSocketAddress address = createInetSocketAddress(lastAddress); ServerQuery template = query.template; ServerQuery squery = ServerQuery.createFromTemplate(address, template); parentContext.fireChannelRead(squery); } else { if (results == null) { // should never happen throw new IllegalStateException("Results container is null when there is no other " + "ChannelHandlerContext to send results."); } // we are storing for bulk access later. results.add(lastAddress); } } assert buf.readableBytes() == 0; // ask for more results this.channelActive(ctx); }