public void onConnect(SocketIOClient client) { join(getName(), client.getSessionId()); storeFactory .pubSubStore() .publish( PubSubStore.JOIN, new JoinLeaveMessage(client.getSessionId(), getName(), getName())); try { for (ConnectListener listener : connectListeners) { listener.onConnect(client); } } catch (Exception e) { exceptionListener.onConnectException(e, client); } }
private <K, V> void join(ConcurrentMap<K, Set<V>> map, K key, V value) { Set<V> clients = map.get(key); if (clients == null) { clients = Collections.newSetFromMap(PlatformDependent.<V, Boolean>newConcurrentHashMap()); Set<V> oldClients = map.putIfAbsent(key, clients); if (oldClients != null) { clients = oldClients; } } clients.add(value); // object may be changed due to other concurrent call if (clients != map.get(key)) { // re-join if queue has been replaced join(map, key, value); } }
public void join(String room, UUID sessionId) { join(roomClients, room, sessionId); join(clientRooms, sessionId, room); }
public void joinRoom(String room, UUID sessionId) { join(room, sessionId); storeFactory .pubSubStore() .publish(PubSubStore.JOIN, new JoinLeaveMessage(sessionId, room, getName())); }