/** * 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; }
public void onTokenizedMessagesReceived(ChatTokenizedMessage[] messages) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < messages.length; ++i) { ChatTokenizedMessage msg = messages[i]; sb.append(msg.displayName).append(": "); for (int t = 0; t < msg.tokenList.length; ++t) { ChatMessageToken token = msg.tokenList[t]; switch (token.type) { case TTV_CHAT_MSGTOKEN_TEXT: { ChatTextMessageToken mt = (ChatTextMessageToken) token; sb.append(mt.text); break; } case TTV_CHAT_MSGTOKEN_IMAGE: { // ChatImageMessageToken mt = (ChatImageMessageToken)token; sb.append("[emoticon]"); break; } } } sb.append("\n"); System.out.println(sb.toString()); } }
/** Draw the chatlog to the chat */ private void drawText() { for (int i = 0; i < log.size(); i++) { chatFont.drawString(0, i * 15 + ChatTop, log.get(i), Color.white); } chatFont.drawString(0, 12 * 15 + ChatTop, messageToSend.toString(), Color.green); }