修改list为线程安全的list

pull/22/head
rays 2021-06-22 16:57:03 +08:00
parent 4921a9ecc6
commit ea8e423e16
1 changed files with 2 additions and 2 deletions

View File

@ -19,7 +19,7 @@ import java.util.concurrent.ConcurrentMap;
public class SessionCenter {
/**
*
*
*/
private static ConcurrentMap<String, List<SocketSession<GunsSocketOperator>>> socketSessionMap = new ConcurrentHashMap<>();
@ -87,7 +87,7 @@ public class SessionCenter {
public static void addSocketSession(SocketSession<GunsSocketOperator> socketSession) {
List<SocketSession<GunsSocketOperator>> socketSessions = socketSessionMap.get(socketSession.getUserId());
if (ObjectUtil.isEmpty(socketSessions)) {
socketSessions = new ArrayList<>();
socketSessions = Collections.synchronizedList(new ArrayList<>());
socketSessionMap.put(socketSession.getUserId(), socketSessions);
}
socketSessions.add(socketSession);