Sketcher2 source code
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.

56 lines
1.1 KiB

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.Input;
import com.jotuntech.sketcher.common.User;
/** Cursor command.
* @author Thor Harald Johansen
*
*/
public class CursorCommand implements Command {
Input input;
/** Constructs an Cursor command. */
public CursorCommand() {
}
/** Constructs an Cursor command.
* @param user Source user.
* @param input Cursor position */
public CursorCommand(Input input) {
this.input = input;
}
public int perform(Client client, User user) {
if(user == null) {
/** Signed in users only. */
return Connection.SEND_NONE;
}
if(user.isViewer()) {
return Connection.SEND_NONE;
}
user.setCursor(input);
/** Return and broadcast. */
return Connection.SEND_OTHERS;
}
public void decode(ByteBuffer in) {
input = new Input();
input.decode(in);
}
public void encode(ByteBuffer out) {
input.encode(out);
}
}