package com.jotuntech.sketcher.server.command; import java.nio.ByteBuffer; import com.jotuntech.sketcher.server.Command; import com.jotuntech.sketcher.server.Connection; import com.jotuntech.sketcher.server.Server; public class ServerMessageCommand implements Command { String text; public ServerMessageCommand() { } public ServerMessageCommand(String text) { this.text = text; } public int perform(Server server, Connection connection) { /** Return silently */ return Connection.SEND_NONE; } public void decode(ByteBuffer in) { StringBuffer textBuffer = new StringBuffer(); while(in.remaining() >= 2) { textBuffer.append(in.getChar()); } text = textBuffer.toString(); } public void encode(ByteBuffer out) { for(int i = 0; i < text.length(); i++) { out.putChar(text.charAt(i)); } } }