/** * 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; }
/** 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); } }
/** Disconnect from the server */ public void disconnect() { client.sendMessage("Disconnected"); client = null; }