Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 private void OnResult(BlockReply block)
 {
     lock (_pendingRequests)
     {
         if (_pendingRequests.TryGetValue(block.RequestID, out ResponseTicket ticket))
         {
             ticket.SetResponseData(block.DataStream);
             _pendingRequests.Remove(block.RequestID);
         }
     }
 }
Exemplo n.º 3
0
 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);
 }