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 VoiceCommand implements Command { boolean voiceEnabled; public VoiceCommand() { } public VoiceCommand(boolean voiceEnabled) { this.voiceEnabled = voiceEnabled; } public int perform(Client client, User user) { if(user.isViewer()) { return Connection.SEND_NONE; } client.setVoiceEnabled(voiceEnabled); return Connection.SEND_OTHERS; } public void decode(ByteBuffer in) { voiceEnabled = in.get() != 0; } public void encode(ByteBuffer out) { out.put((byte) (voiceEnabled ? 0xFF : 0x00)); } }