Beispiel #1
0
 private void doMsg(String cmd) {
   cmd = cmd.trim();
   int pos = cmd.indexOf(' '); // find tell whom
   if (pos < 0) return; // no message on the line
   String dst = cmd.substring(0, pos);
   String msg = cmd.substring(pos + 1);
   msg = msg.trim();
   if (msg == null) msg = " ";
   if (onlineUsers.containsKey(dst)) {
     ClientThread c = (ClientThread) onlineUsers.get(dst);
     c.writeLine("*** [" + myName + "] " + msg);
   } else {
     writeLine("CHAT *** " + dst + " not in the ROOM ***");
   }
 }
Beispiel #2
0
 private void doBcast(String msg) {
   for (Enumeration e = onlineUsers.elements(); e.hasMoreElements(); ) {
     ClientThread c = (ClientThread) e.nextElement();
     if (c != this) c.writeLine(msg);
   }
 }