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.

49 lines
1019 B

package com.jotuntech.sketcher.server.command;
import java.nio.ByteBuffer;
import com.jotuntech.sketcher.common.Brush;
import com.jotuntech.sketcher.common.User;
import com.jotuntech.sketcher.server.Command;
import com.jotuntech.sketcher.server.Connection;
import com.jotuntech.sketcher.server.Server;
public class SetBrushCommand implements Command {
Brush brush;
public SetBrushCommand() {
}
public SetBrushCommand(Brush brush) {
this.brush = brush;
}
public int perform(Server server, Connection connection) {
return perform(connection.getUser()) ? Connection.SEND_OTHERS : Connection.SEND_NONE;
}
private boolean perform(User user) {
if(user == null) {
/** Signed in users only */
return false;
}
if(user.isViewer()) {
return false;
}
user.setBrush(brush);
return true;
}
public void decode(ByteBuffer in) {
brush = new Brush();
brush.decode(in);
}
public void encode(ByteBuffer out) {
brush.encode(out);
}
}