Example #1
0
        private void DispatchResponse(byte[] bytes)
        {
            ResponseBase response = RequestSerializer.Deserialize <ResponseBase>(bytes);

            lock (responses)
            {
                if (responses.ContainsKey(response.Token))
                {
                    responses[response.Token] = response;
                }
            }
        }
Example #2
0
 public async Task SendResponse(ResponseBase response)
 {
     if (Connected)
     {
         try
         {
             byte[] data = RequestSerializer.Serialize(response);
             await SendCommand(CommandTypes.Response, data);
         }
         catch (Exception) {}
     }
 }
Example #3
0
        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));
        }