private void DataReceived(string data) { var request = Serialization.FromJson <RpcMessage>(data); if (request.Id != null && string.IsNullOrEmpty(request.Method)) { // Response requestResponses.TryAdd(request.Id.Value, data); } else if (request.Id != null && !string.IsNullOrEmpty(request.Method)) { // Request RequestReceived?.BeginInvoke(this, new JsonRpcRequestEventArgs() { Request = Serialization.FromJson <JsonRpcRequest>(data) }, EventEndCallback <JsonRpcRequestEventArgs>, null); } else if (request.Id == null) { // Notification NotificationReceived?.BeginInvoke(this, new JsonRpcNotificationEventArgs() { Notification = Serialization.FromJson <JsonRpcNotification>(data) }, EventEndCallback <JsonRpcNotificationEventArgs>, null); } else { logger.Error("Recevied invalid RPC message:"); logger.Error(data); } }