Commit 76ccb0b0 authored by duanruiming's avatar duanruiming

[update] channel缓存非空校验

parent 82532620
...@@ -60,8 +60,12 @@ public class NettyServer { ...@@ -60,8 +60,12 @@ public class NettyServer {
} }
public static void sendMessage(String ip, int port, String message) { public static void sendMessage(String ip, int port, String message) {
Channel channel = channelGroup.find(IP_PORT_CHANNEL_ID_MAP.get(StringUtils.join(ip, ":", port))); String key = StringUtils.join(ip, ":", port);
channel.writeAndFlush(message); if (!IP_PORT_CHANNEL_ID_MAP.isEmpty()) {
ChannelId channelId = IP_PORT_CHANNEL_ID_MAP.get(key);
Channel channel = channelGroup.find(channelId);
channel.writeAndFlush(message);
}
} }
public static Object sendMessage(String ip, int port, String message, String command) { public static Object sendMessage(String ip, int port, String message, String command) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment