@Test(expected = IllegalArgumentException.class) public void test_broadcast_exception_on_null_packet() { final SocketIoAdapter adapter = ADAPTER_FACTORY.createAdapter(null); adapter.broadcast(null, null, null); }
@Override public synchronized void broadcast(Packet packet, String[] rooms, String[] socketsExcluded) throws IllegalArgumentException { if (packet == null) { throw new IllegalArgumentException("packet must not be null."); } socketsExcluded = (socketsExcluded != null)? socketsExcluded : EMPTY_SOCKET_EXCLUSION; final Set<String> socketsExcludedSet = new HashSet<>(); Collections.addAll(socketsExcludedSet, socketsExcluded); final Map<String, SocketIoSocket> connectedSockets = mNamespace.getConnectedSockets(); if (rooms != null) { final Set<String> sentSocketIds = new HashSet<>(); for (String room : rooms) { if (mRoomSockets.containsKey(room)) { final Set<SocketIoSocket> sockets = mRoomSockets.get(room); for (SocketIoSocket socket : sockets) { if (!socketsExcludedSet.contains(socket.getId()) && !sentSocketIds.contains(socket.getId()) && connectedSockets.containsKey(socket.getId())) { socket.sendPacket(packet); sentSocketIds.add(socket.getId()); } } } } } else { for (String socketId : mSocketRooms.keySet()) { if (!socketsExcludedSet.contains(socketId)) { final SocketIoSocket socket = connectedSockets.get(socketId); if (socket != null) { socket.sendPacket(packet); } } } } }
SocketIoMemoryAdapter extends SocketIoAdapter { @Override public synchronized void broadcast(Packet packet, String[] rooms, String[] socketsExcluded) throws IllegalArgumentException { if (packet == null) { throw new IllegalArgumentException("packet must not be null."); } socketsExcluded = (socketsExcluded != null)? socketsExcluded : EMPTY_SOCKET_EXCLUSION; final Set<String> socketsExcludedSet = new HashSet<>(); Collections.addAll(socketsExcludedSet, socketsExcluded); final Map<String, SocketIoSocket> connectedSockets = mNamespace.getConnectedSockets(); if (rooms != null) { final Set<String> sentSocketIds = new HashSet<>(); for (String room : rooms) { if (mRoomSockets.containsKey(room)) { final Set<SocketIoSocket> sockets = mRoomSockets.get(room); for (SocketIoSocket socket : sockets) { if (!socketsExcludedSet.contains(socket.getId()) && !sentSocketIds.contains(socket.getId()) && connectedSockets.containsKey(socket.getId())) { socket.sendPacket(packet); sentSocketIds.add(socket.getId()); } } } } } else { for (String socketId : mSocketRooms.keySet()) { if (!socketsExcludedSet.contains(socketId)) { final SocketIoSocket socket = connectedSockets.get(socketId); if (socket != null) { socket.sendPacket(packet); } } } } } }
SocketIoMemoryAdapter extends SocketIoAdapter { @Override public synchronized void broadcast(Packet packet, String[] rooms, String[] socketsExcluded) throws IllegalArgumentException { if (packet == null) { throw new IllegalArgumentException("packet must not be null."); } socketsExcluded = (socketsExcluded != null)? socketsExcluded : EMPTY_SOCKET_EXCLUSION; final Set<String> socketsExcludedSet = new HashSet<>(); Collections.addAll(socketsExcludedSet, socketsExcluded); final Map<String, SocketIoSocket> connectedSockets = mNamespace.getConnectedSockets(); if (rooms != null) { final Set<String> sentSocketIds = new HashSet<>(); for (String room : rooms) { if (mRoomSockets.containsKey(room)) { final Set<SocketIoSocket> sockets = mRoomSockets.get(room); for (SocketIoSocket socket : sockets) { if (!socketsExcludedSet.contains(socket.getId()) && !sentSocketIds.contains(socket.getId()) && connectedSockets.containsKey(socket.getId())) { socket.sendPacket(packet); sentSocketIds.add(socket.getId()); } } } } } else { for (String socketId : mSocketRooms.keySet()) { if (!socketsExcludedSet.contains(socketId)) { final SocketIoSocket socket = connectedSockets.get(socketId); if (socket != null) { socket.sendPacket(packet); } } } } } private  SocketIoMemoryAdapter(SocketIoNamespace namespace); }
SocketIoMemoryAdapter extends SocketIoAdapter { @Override public synchronized void broadcast(Packet packet, String[] rooms, String[] socketsExcluded) throws IllegalArgumentException { if (packet == null) { throw new IllegalArgumentException("packet must not be null."); } socketsExcluded = (socketsExcluded != null)? socketsExcluded : EMPTY_SOCKET_EXCLUSION; final Set<String> socketsExcludedSet = new HashSet<>(); Collections.addAll(socketsExcludedSet, socketsExcluded); final Map<String, SocketIoSocket> connectedSockets = mNamespace.getConnectedSockets(); if (rooms != null) { final Set<String> sentSocketIds = new HashSet<>(); for (String room : rooms) { if (mRoomSockets.containsKey(room)) { final Set<SocketIoSocket> sockets = mRoomSockets.get(room); for (SocketIoSocket socket : sockets) { if (!socketsExcludedSet.contains(socket.getId()) && !sentSocketIds.contains(socket.getId()) && connectedSockets.containsKey(socket.getId())) { socket.sendPacket(packet); sentSocketIds.add(socket.getId()); } } } } } else { for (String socketId : mSocketRooms.keySet()) { if (!socketsExcludedSet.contains(socketId)) { final SocketIoSocket socket = connectedSockets.get(socketId); if (socket != null) { socket.sendPacket(packet); } } } } } private  SocketIoMemoryAdapter(SocketIoNamespace namespace); @Override synchronized void broadcast(Packet packet, String[] rooms, String[] socketsExcluded); @Override synchronized void add(String room, SocketIoSocket socket); @Override synchronized void remove(String room, SocketIoSocket socket); @Override SocketIoSocket[] listClients(String room); @Override String[] listClientRooms(SocketIoSocket socket); }
SocketIoMemoryAdapter extends SocketIoAdapter { @Override public synchronized void broadcast(Packet packet, String[] rooms, String[] socketsExcluded) throws IllegalArgumentException { if (packet == null) { throw new IllegalArgumentException("packet must not be null."); } socketsExcluded = (socketsExcluded != null)? socketsExcluded : EMPTY_SOCKET_EXCLUSION; final Set<String> socketsExcludedSet = new HashSet<>(); Collections.addAll(socketsExcludedSet, socketsExcluded); final Map<String, SocketIoSocket> connectedSockets = mNamespace.getConnectedSockets(); if (rooms != null) { final Set<String> sentSocketIds = new HashSet<>(); for (String room : rooms) { if (mRoomSockets.containsKey(room)) { final Set<SocketIoSocket> sockets = mRoomSockets.get(room); for (SocketIoSocket socket : sockets) { if (!socketsExcludedSet.contains(socket.getId()) && !sentSocketIds.contains(socket.getId()) && connectedSockets.containsKey(socket.getId())) { socket.sendPacket(packet); sentSocketIds.add(socket.getId()); } } } } } else { for (String socketId : mSocketRooms.keySet()) { if (!socketsExcludedSet.contains(socketId)) { final SocketIoSocket socket = connectedSockets.get(socketId); if (socket != null) { socket.sendPacket(packet); } } } } } private  SocketIoMemoryAdapter(SocketIoNamespace namespace); @Override synchronized void broadcast(Packet packet, String[] rooms, String[] socketsExcluded); @Override synchronized void add(String room, SocketIoSocket socket); @Override synchronized void remove(String room, SocketIoSocket socket); @Override SocketIoSocket[] listClients(String room); @Override String[] listClientRooms(SocketIoSocket socket);  }