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); })); }
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)); }