Java Code Examples for io.netty.channel.socket.SocketChannel#writeAndFlush()
The following examples show how to use
io.netty.channel.socket.SocketChannel#writeAndFlush() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfServiceImpl.java From lightconf with GNU General Public License v3.0 | 5 votes |
private void pushConfToApplication(Conf conf, String confTypeUpdate, String uuid) { SocketChannel socketChannel = (SocketChannel) NettyChannelMap.get(uuid); // 若socketChanel不为空,更新配置到客户端. if (socketChannel != null) { PushMsg pushMsg = new PushMsg(); pushMsg.setConfType(confTypeUpdate); pushMsg.setKey(conf.getConfKey()); pushMsg.setValue(conf.getConfValue()); pushMsg.setType(MsgType.PUSH_CONF); socketChannel.writeAndFlush(pushMsg); LOGGER.info(">>>>>> push conf value to application"); } }
Example 2
Source File: ClientBootstrap.java From lightconf with GNU General Public License v3.0 | 5 votes |
public static void login(SocketChannel socketChannel, String uuid) { try { LoginMsg loginMsg = new LoginMsg(); loginMsg.setClientId(uuid); loginMsg.setUserName("wuhf"); loginMsg.setPassword("abcd"); socketChannel.writeAndFlush(loginMsg); } catch (Exception e) { e.printStackTrace(); } }
Example 3
Source File: GoAwayTest.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
public void goAway(SocketChannel ch, int lastStreamId) { ByteBuf b = ch.alloc().buffer(9 + 8); // Frame header b.writeMedium(8); // Payload length b.writeByte(0x7); // Type = GOAWAY b.writeByte(0x0); // Flags b.writeInt(0); // 0 = connection frame // GOAWAY payload b.writeInt(lastStreamId); b.writeInt(0); // Error code ch.writeAndFlush(b); }
Example 4
Source File: GoAwayTest.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
public void data(SocketChannel ch, int streamId, byte[] payload) { ByteBuf b = ch.alloc().buffer(9 + payload.length); // Header b.writeMedium(payload.length); // Payload length b.writeByte(0); // Type = DATA b.writeByte(0x1); // 0x1 = EOF b.writeInt(streamId); // Payload b.writeBytes(payload); ch.writeAndFlush(b); }
Example 5
Source File: NettyServerBootstrap.java From netty with Apache License 2.0 | 5 votes |
public static void main(String []args) throws InterruptedException { NettyServerBootstrap bootstrap=new NettyServerBootstrap(9999); while (true){ SocketChannel channel=(SocketChannel)NettyChannelMap.get("001"); if(channel!=null){ AskMsg askMsg=new AskMsg(); channel.writeAndFlush(askMsg); } TimeUnit.SECONDS.sleep(1000); } }