private void DispatchResponse(byte[] bytes) { ResponseBase response = RequestSerializer.Deserialize <ResponseBase>(bytes); lock (responses) { if (responses.ContainsKey(response.Token)) { responses[response.Token] = response; } } }
public async Task SendResponse(ResponseBase response) { if (Connected) { try { byte[] data = RequestSerializer.Serialize(response); await SendCommand(CommandTypes.Response, data); } catch (Exception) {} } }
private void DispatchRequest(byte[] bytes) { RequestBase request = RequestSerializer.Deserialize <RequestBase>(bytes); ResponseBase response = null; lock (handlers) { if (handlers.ContainsKey(request.GetType())) { response = handlers[request.GetType()](request); } } if (response == null) { response = request.CreateResponse(); } Task.Run(async() => await SendResponse(response)); }