Example #1
0
 public static AsyncAction ProcessResponse <TInput>(this RequestBase request, WebSocket session, TInput objectToSend)
 {
     return(AsyncTask.StartNew(delegate
     {
         byte[] array = request.CreateResponse(objectToSend).SerializeProto();
         session.Send(array, 0, array.Length);
     }));
 }
Example #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));
        }