You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
864 B
37 lines
864 B
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));
|
|
}
|
|
}
|
|
}
|
|
|