private void OnResponse(byte[] response) { Task.Run(() => { var zmqResponse = ZmqResponse.FromBinary(response); TaskCompletionSource <ResponseData> callback; if (this.requestCallbacks.TryRemove(zmqResponse.RequestId, out callback)) { callback.SetResult(zmqResponse.Response); } }); }
private void OnRequest(byte[] callerId, byte[] requestBytes) { Task.Run(() => { var zmqRequest = ZmqRequest.FromBinary(requestBytes); var service = this.serviceFactory.CreateService(zmqRequest.Request.Service); service.Process(zmqRequest.Request) .ContinueWith(t => { var response = t.Result; var zmqResponse = new ZmqResponse(zmqRequest.Id, response); var zmqResponseBytes = zmqResponse.ToBinary(); this.responsesQueue.TryAdd(new Tuple <byte[], byte[]>(callerId, zmqResponseBytes)); }); }); }
private void OnRequest(byte[] callerId, byte[] requestBytes) { Task.Run(() => { var zmqRequest = ZmqRequest.FromBinary(requestBytes); var service = this.serviceFactory.CreateService(zmqRequest.Request.Service); service.Process(zmqRequest.Request) .ContinueWith(t => { var response = t.Result; var zmqResponse = new ZmqResponse(zmqRequest.Id, response); var zmqResponseBytes = zmqResponse.ToBinary(); this.responsesQueue.TryAdd(new Tuple<byte[], byte[]>(callerId, zmqResponseBytes)); }); }); }