private void HandlerMessage(string message) { if (_socket != null) { RemoteControlOnMessageArgs args = new RemoteControlOnMessageArgs(); args.message = message; string response = OnMessage(this, args); if (response != null) { _socket.Send(response); } } }
private string MessageHandler(object sender, RemoteControlOnMessageArgs message) { RemoteControlData data = JsonConvert.DeserializeObject <RemoteControlData>(message.message); Func <RemoteControlData, RemoteControlData> route; if (routes.TryGetValue(data.type, out route)) { data = route(data); } else { data = getUnknownCommand(data); } return(data != null?JsonConvert.SerializeObject(data) : null); }