demand scenario:
Smart Home Gateway (hereinafter referred to as gateway), needs to communicate with netty server (hereinafter referred to as netty), netty and gateway need to maintain a long connection (in other words, both netty and gateway will actively send messages to each other)
problems encountered:
how does netty actively send messages to gateway as a server? I try to use a map to bind the id of the channelSocket to the channelSocket when each gateway connects to the netty (TCP/IP)
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
System.out.println("write handler");
ctx.writeAndFlush(msg);
}
but in the end, the client did not receive any message. How can netty actively send a message to the client?