mirror of
https://github.com/tiennm99/caro.git
synced 2026-10-03 07:12:15 +00:00
fix #27
This commit is contained in:
1 parent
182ea6e4e0
commit
2bc498f07a
2 files changed
+11
-1
No files matched your search
@@ -2,6 +2,7 @@ package org.nico.ratel.landlords.server;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
@@ -28,6 +29,8 @@ public class ServerContains {
|
||||
*/
|
||||
public final static Map<Integer, ClientSide> CLIENT_SIDE_MAP = new ConcurrentSkipListMap<>();
|
||||
|
||||
public final static Map<String, Integer> CHANNEL_ID_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
private final static AtomicInteger CLIENT_ATOMIC_ID = new AtomicInteger(1);
|
||||
|
||||
private final static AtomicInteger SERVER_ATOMIC_ID = new AtomicInteger(1);
|
||||
|
||||
+8
-1
@@ -78,7 +78,13 @@ public class TransferHandler extends ChannelInboundHandlerAdapter{
|
||||
}
|
||||
|
||||
private int getId(Channel channel){
|
||||
return ((InetSocketAddress)channel.remoteAddress()).getPort();
|
||||
String longId = channel.id().asLongText();
|
||||
Integer clientId = ServerContains.CHANNEL_ID_MAP.get(longId);
|
||||
if(null == clientId){
|
||||
clientId = ServerContains.getClientId();
|
||||
ServerContains.CHANNEL_ID_MAP.put(longId, clientId);
|
||||
}
|
||||
return clientId;
|
||||
}
|
||||
|
||||
private void clientOfflineEvent(Channel channel){
|
||||
@@ -89,4 +95,5 @@ public class TransferHandler extends ChannelInboundHandlerAdapter{
|
||||
ServerEventListener.get(ServerEventCode.CODE_CLIENT_OFFLINE).call(client, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user