/** * Handle requests from the client of this connection. Requests will be differentiated by message * type. */ public void messageReceived( WonderlandClientSender sender, WonderlandClientID clientID, Message message) { ResponseMessage response; if (message instanceof SecretRequestMessage) { response = handleSecretRequest(sender, clientID, (SecretRequestMessage) message); } else if (message instanceof TakeControlRequestMessage) { response = handleTakeControl(sender, clientID, message); } else { logger.warning("Unrecognized message type: " + message.getClass() + " from " + clientID); response = new ErrorMessage( message.getMessageID(), "Unrecognized message type: " + message.getClass()); } // send a response back to the requester if (response != null) { sender.send(clientID, response); } }
public ResponseMessage handleTakeControl( WonderlandClientSender sender, WonderlandClientID clientID, Message message) { // if we got here, the client has permission to take control. Just // send back an OK message return new OKMessage(message.getMessageID()); }