From f3c3ab3330aca7c4fe7cdcbe1fb0907e8ab40869 Mon Sep 17 00:00:00 2001 From: talent-tan Date: Fri, 1 Feb 2019 18:16:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/tio/core/ChannelContext.java | 2 +- src/core/src/main/java/org/tio/core/Tio.java | 34 +++++++++---------- .../java/org/tio/core/maintain/Groups.java | 3 +- src/parent/pom.xml | 2 +- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/core/src/main/java/org/tio/core/ChannelContext.java b/src/core/src/main/java/org/tio/core/ChannelContext.java index 7bbfd45f..90da6b82 100644 --- a/src/core/src/main/java/org/tio/core/ChannelContext.java +++ b/src/core/src/main/java/org/tio/core/ChannelContext.java @@ -348,7 +348,7 @@ public void setAttribute(Object value) { /** * @param remoteNode the remoteNode to set */ - private void setClientNode(Node clientNode) { + public void setClientNode(Node clientNode) { if (!this.groupContext.isShortConnection) { if (this.clientNode != null) { groupContext.clientNodes.remove(this); diff --git a/src/core/src/main/java/org/tio/core/Tio.java b/src/core/src/main/java/org/tio/core/Tio.java index 3cdab9ae..d0ae6840 100644 --- a/src/core/src/main/java/org/tio/core/Tio.java +++ b/src/core/src/main/java/org/tio/core/Tio.java @@ -200,12 +200,12 @@ public static Boolean bSendToGroup(GroupContext groupContext, String group, Pack /** * 发消息给指定ChannelContext id - * @param channelId + * @param channelContextId * @param packet * @author tanyaowu */ - public static Boolean bSendToId(GroupContext groupContext, String channelId, Packet packet) { - return sendToId(groupContext, channelId, packet, true); + public static Boolean bSendToId(GroupContext groupContext, String channelContextId, Packet packet) { + return sendToId(groupContext, channelContextId, packet, true); } /** @@ -438,12 +438,12 @@ public static ChannelContext getChannelContextByClientNode(GroupContext groupCon /** * 根据id获取ChannelContext - * @param channelId + * @param channelContextId * @return * @author tanyaowu */ - public static ChannelContext getChannelContextById(GroupContext groupContext, String channelId) { - return groupContext.ids.find(groupContext, channelId); + public static ChannelContext getChannelContextById(GroupContext groupContext, String channelContextId) { + return groupContext.ids.find(groupContext, channelContextId); } /** @@ -640,15 +640,15 @@ public static void notifyClusterForGroup(GroupContext groupContext, String group } /** - * 在集群环境下,把channelId消息通知到集群中的其它机器 + * 在集群环境下,把channelContextId消息通知到集群中的其它机器 * @param groupContext - * @param channelId + * @param channelContextId * @param packet */ - public static void notifyClusterForId(GroupContext groupContext, String channelId, Packet packet) { + public static void notifyClusterForId(GroupContext groupContext, String channelContextId, Packet packet) { TioClusterConfig tioClusterConfig = groupContext.getTioClusterConfig(); TioClusterVo tioClusterVo = new TioClusterVo(packet); - tioClusterVo.setChannelId(channelId); + tioClusterVo.setChannelId(channelContextId); tioClusterConfig.publish(tioClusterVo); } @@ -1025,30 +1025,30 @@ private static Boolean sendToGroup(GroupContext groupContext, String group, Pack /** * 发消息给指定ChannelContext id - * @param channelId + * @param channelContextId * @param packet * @author tanyaowu */ - public static Boolean sendToId(GroupContext groupContext, String channelId, Packet packet) { - return sendToId(groupContext, channelId, packet, false); + public static Boolean sendToId(GroupContext groupContext, String channelContextId, Packet packet) { + return sendToId(groupContext, channelContextId, packet, false); } /** * 发消息给指定ChannelContext id - * @param channelId + * @param channelContextId * @param packet * @param isBlock * @return * @author tanyaowu */ - private static Boolean sendToId(GroupContext groupContext, String channelId, Packet packet, boolean isBlock) { - ChannelContext channelContext = Tio.getChannelContextById(groupContext, channelId); + private static Boolean sendToId(GroupContext groupContext, String channelContextId, Packet packet, boolean isBlock) { + ChannelContext channelContext = Tio.getChannelContextById(groupContext, channelContextId); if (channelContext == null) { if (groupContext.isCluster() && !packet.isFromCluster()) { TioClusterConfig tioClusterConfig = groupContext.getTioClusterConfig(); if (tioClusterConfig.isCluster4channelId()) { - notifyClusterForId(groupContext, channelId, packet); + notifyClusterForId(groupContext, channelContextId, packet); } } return false; diff --git a/src/core/src/main/java/org/tio/core/maintain/Groups.java b/src/core/src/main/java/org/tio/core/maintain/Groups.java index 65a33f5e..8177d1bc 100644 --- a/src/core/src/main/java/org/tio/core/maintain/Groups.java +++ b/src/core/src/main/java/org/tio/core/maintain/Groups.java @@ -237,7 +237,8 @@ public void unbind(String groupid, ChannelContext channelContext, boolean delete if (setWithLock != null) { boolean ss = setWithLock.remove(channelContext); if (!ss) { - log.error("{}, 移除失败", channelContext); + log.error("{}, 移除失败, cid:{}", channelContext, channelContext.getId()); + } if (deleteFromChannelContext) { diff --git a/src/parent/pom.xml b/src/parent/pom.xml index 553c4aba..cf4dbd0a 100644 --- a/src/parent/pom.xml +++ b/src/parent/pom.xml @@ -62,7 +62,7 @@ 1.18 1.2.56 6.14.3 - 4.4.3 + 4.4.4 3.6.1 1.9.3 1.4