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.
41 lines
969 B
41 lines
969 B
package com.jotuntech.sketcher.client.command;
|
|
|
|
import java.nio.ByteBuffer;
|
|
|
|
import com.jotuntech.sketcher.client.Client;
|
|
import com.jotuntech.sketcher.client.Command;
|
|
import com.jotuntech.sketcher.client.Connection;
|
|
import com.jotuntech.sketcher.common.User;
|
|
|
|
public class ServerMessageCommand implements Command {
|
|
String text;
|
|
|
|
public ServerMessageCommand() {
|
|
}
|
|
|
|
public ServerMessageCommand(String text) {
|
|
this.text = text;
|
|
}
|
|
|
|
public int perform(Client client, User user) {
|
|
/** Notify the user */
|
|
client.getUserInterface().println(text);
|
|
|
|
/** 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));
|
|
}
|
|
}
|
|
}
|
|
|