Beispiel #1
0
 /**
  * Versendet eine Message.
  *
  * @param m Message zum versandt.
  */
 public void sendMessage(Message m) throws MessagingException {
   List<String> receiver = m.getReceiver();
   addMessageHistory(m);
   if (m instanceof RoomMessage) {
     textMmessageSender.sendMessageToRoom((RoomMessage) m);
   } else if (m instanceof SingleMessage) {
     m.setSender(simConfiguration.getUsername());
     String singleReceiver = receiver.get(0);
     User user = userService.getUser(singleReceiver);
     textMmessageSender.sendMessage(user, m);
   } else if (m instanceof BroadcastMessage) {
     m.setSender(simConfiguration.getUsername());
     textMmessageSender.sendMessageToAllUsers(m);
   }
 }
Beispiel #2
0
 public void addMessageHistory(Message m) {
   if (m instanceof SingleMessage) {
     getHistory(m.getReceiver().get(0)).add(m);
   } else if (m instanceof BroadcastMessage) {
     getHistory(simConfiguration.getStreamTabName()).add(m);
   } else if (m instanceof RoomMessage) {
     RoomMessage rm = (RoomMessage) m;
     getHistory(rm.getRoomName()).add(m);
   }
 }