Beispiel #1
0
 /**
  * Send a message to the client
  *
  * @return true if message is not empty
  */
 public boolean sendMessage() {
   if (messageToSend.length() == 0) return false;
   client.sendMessage(messageToSend.toString());
   addMessageToLog("You: " + messageToSend.toString());
   messageToSend.delete(0, messageToSend.length());
   return true;
 }
Beispiel #2
0
  /** Poll the client for a message, add it to the log if not null */
  private void getMessageFromClient() {
    String rec = client.receiveMessage();

    if (rec != null) {
      addMessageToLog(rec);
    }
  }
Beispiel #3
0
 /** Disconnect from the server */
 public void disconnect() {
   client.sendMessage("Disconnected");
   client = null;
 }