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

            lock (responses)
            {
                if (responses.ContainsKey(response.Token))
                {
                    responses[response.Token] = response;
                }
            }
        }
Ejemplo n.º 2
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));
        }