socketMapping.remove(userId);
}
@Override
public void login(Serializable userId) {
Socket userSocket = socketMapping.get(userId);
// 登录了给所有在线的人发广播
for (Entry<Serializable, Socket> entry : socketMapping.entrySet()) {
Serializable id = entry.getKey();
Socket socket = entry.getValue();
if (id.equals(userId)) {
continue;
}
JSONObject message = new JSONObject();
message.put(COMMAND_KEY, COMMAND_LOGIN);
message.put("userId", userId);
socket.send(message.toString());
JSONObject message2 = new JSONObject();
message2.put(COMMAND_KEY, COMMAND_LOGIN);
message2.put("userId", id);
userSocket.send(message2.toString());