コード例 #1
0
 public void localChatText(String text) {
   String[] commands = text.split(" ");
   if (commands[0].equals("client")) {
     if (commands.length == 2) {
       client.init(commands[1], "localhost", 9001, "localhost", 9000);
       chatFrame.appendRow("default", "");
     } else if (commands.length == 6) {
       client.init(
           commands[1],
           commands[2],
           NumberTools.toInt(commands[3], 9005),
           commands[4],
           NumberTools.toInt(commands[5], 9000));
     } else {
       chatFrame.appendRow(
           "default",
           "To start the client enter: client <username> <localip> <localport> <serverip> <serverport>");
       return;
     }
     chatFrame.appendRow("default", ".");
     chatFrame.appendRow("default", "Try to connect...can take a while...");
   } else if (commands[0].equals("server")) {
     if (commands.length == 1) {
       server.init("localhost", 9000);
     } else if (commands.length == 3) {
       server.init(commands[1], NumberTools.toInt(commands[2], 9000));
     } else {
       chatFrame.appendRow(
           "default", "To start the client enter: client <localip> <serverip> <serverport>");
       return;
     }
     chatFrame.appendRow("default", ".");
     chatFrame.appendRow("default", "Server created...");
   } else {
     if (client.getChatService() != null)
       client
           .getChatService()
           .sendMessage(client.getCommonWorld().getUserManager().getAppUser(), text);
   }
 }
コード例 #2
0
 @Override
 public CommonWorld getCommonWorld() {
   return client.getCommonWorld();
 }