Ejemplo n.º 1
0
 /**
  * Sends messages to UI
  *
  * @param type the type of the message (SERVER,CLIENT,NORMAL)
  * @param message
  */
 private void sendMessage(String type, String message) {
   _mr.toUI(type + message);
 }
Ejemplo n.º 2
0
  /**
   * Processes the other commands
   *
   * @param command
   * @param message
   */
  private boolean processMessageCommand(String command, String message) {
    boolean processed = false;

    String args[] = new String[MAXARGC];
    int counter = 0;

    StringTokenizer st = new StringTokenizer(message, " ");
    while (st.hasMoreTokens() && counter < MAXARGC - 1) {
      args[counter] = st.nextToken();
      counter++;
    }

    // do the proccessing
    if (command.equalsIgnoreCase("NAME")) {
      _user = args[1];
      processed = true;
    } else if (command.equalsIgnoreCase("PASS")) {
      _pass = args[1];
      processed = true;
    } else if (command.equalsIgnoreCase("LOGIN")) {
      sendServerMessage(
          "<mobber><login><name>"
              + _user
              + "</name><password>"
              + _pass
              + "</password></login></mobber>");
      processed = true;
    } else if (command.equalsIgnoreCase("LOGOUT")) {
      sendServerMessage("<mobber><logout /></mobber>");
      _status = NOTCONNECTED;
      processed = true;
    } else if (command.equalsIgnoreCase("EXIT")) {
      _mr.exit();
      processed = true;
    } else if (command.equalsIgnoreCase("CONNECT")) {
      connect(args[1], (new Integer(args[2])).intValue());
      sendMessage(CLIENT, "try to connect");
      if (_status == CONNECTED) sendMessage(CLIENT, "connected to:" + args[1] + ":" + args[2]);
      processed = true;
    } else if (command.equalsIgnoreCase("JOINGROUP")) {
      sendServerMessage("<mobber><joingroup><group>" + args[1] + "</group></joingroup></mobber>");
      processed = true;
    } else if (command.equalsIgnoreCase("PARTGROUP")) {
      sendServerMessage("<mobber><partgroup><group>" + args[1] + "</group></partgroup></mobber>");
      processed = true;
    } else if (command.equalsIgnoreCase("KICK")) {
      sendServerMessage(
          "<mobber><kick><group>"
              + _group
              + "</group><user>"
              + args[1]
              + "</user></kick></mobber>");
      processed = true;
    } else if (command.equalsIgnoreCase("LISTUSER")) {
      sendServerMessage("<mobber><listuser /></mobber>");
      processed = true;
    } else if (command.equalsIgnoreCase("LISTGROUP")) {
      sendServerMessage("<mobber><listgroup /></mobber>");
      processed = true;
    }
    return processed;
  }