public static void send(ChatEvent.Event event, User user, Room room) { synchronized (eventStreamsMap) { for (User member : room.members) { if (eventStreamsMap.containsKey(member.name)) { List<EventStream<Event>> streams = eventStreamsMap.get(member.name); for (EventStream<Event> stream : streams) { Logger.info("publish called. %s", member.name); stream.publish(event); } } } } }
private static void publishOnlineEvent(User user) { Online online = new Online(user.name, user.fullname); List<Room> rooms = Room.findJoinedRoomsByUser(user); for (Room room : rooms) { for (User member : room.members) { if (eventStreamsMap.containsKey((member.name))) { List<EventStream<Event>> userStreams = eventStreamsMap.get(member.name); for (EventStream<Event> userStream : userStreams) { userStream.publish(online); } } } } }