Skip to content

Commit

Permalink
udp gateway 模式下取消redis踢人消息订阅
Browse files Browse the repository at this point in the history
  • Loading branch information
夜色 committed Dec 11, 2016
1 parent 695a1d6 commit 0e67f51
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Expand Up @@ -54,12 +54,7 @@ public void onMessage(final String channel, final String message) {
}

public void subscribe(String channel, MessageListener listener) {
List<MessageListener> listeners = subscribes.get(channel);
if (listeners == null) {
listeners = Lists.newArrayList();
subscribes.put(channel, listeners);
}
listeners.add(listener);
subscribes.computeIfAbsent(channel, k -> Lists.newArrayList()).add(listener);
RedisManager.I.subscribe(Subscriber.holder, channel);
}
}
Expand Up @@ -51,9 +51,12 @@
public final class RouterChangeListener extends EventConsumer implements MessageListener {
public static final String KICK_CHANNEL_ = "/mpush/kick/";
private final String kick_channel = KICK_CHANNEL_ + GS_NODE.getHostAndPort();
private final boolean udpGateway = CC.mp.net.udpGateway();

public RouterChangeListener() {
ListenerDispatcher.I.subscribe(getKickChannel(), this);
if (!udpGateway) {
ListenerDispatcher.I.subscribe(getKickChannel(), this);
}
}

public String getKickChannel() {
Expand Down Expand Up @@ -113,7 +116,7 @@ private void kickRemote(String userId, RemoteRouter remoteRouter) {
return;
}

if (CC.mp.net.udpGateway()) {
if (udpGateway) {
Connection connection = GatewayUDPConnector.I().getConnection();
GatewayKickUserMessage.build(connection)
.setUserId(userId)
Expand Down

0 comments on commit 0e67f51

Please sign in to comment.