internal async Task OnObjectCall(BlockCall request) { var reply = new BlockReply { RequestID = request.RequestID }; try { if (CanCall(request)) { var resultStream = new MemoryStream(); if (request.ObjectID < 0) { OnChannelCall(request, resultStream); } else { _serviceCache.CallObject(request, resultStream); } reply.Success = true; reply.DataStream = resultStream; } else { var ex = new UnauthorizedAccessException("Access token error"); reply = BlockReply.BuildFromException(ex, request.RequestID); } } catch (Exception ex) { reply = BlockReply.BuildFromException(ex, request.RequestID); } await SendBlockAsync(reply); }
private void OnResult(BlockReply block) { lock (_pendingRequests) { if (_pendingRequests.TryGetValue(block.RequestID, out ResponseTicket ticket)) { ticket.SetResponseData(block.DataStream); _pendingRequests.Remove(block.RequestID); } } }
internal Task OnObjectReply(BlockReply block) { if (block.Success) { OnResult(block); } else { var exceptionMessage = new Packer(block.DataStream).ReadString(); OnRemoteException(exceptionMessage, block.RequestID); } return(Task.CompletedTask); }