コード例 #1
0
ファイル: MessageContext.java プロジェクト: anrub/SIM
 /**
  * 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);
   }
 }
コード例 #2
0
ファイル: MessageContext.java プロジェクト: anrub/SIM
 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);
   }
 }