Beispiel #1
0
 public void HandleInbound(RpcResponse response)
 {
     lock (m_PendingQueries)
     {
         if (m_PendingQueries.TryGetValue(response.QueryId, out RequestToken requestToken))
         {
             requestToken.Response = response;
             try
             {
                 requestToken.Completed.Set();
             }
             catch (ObjectDisposedException)
             {
             }
             m_PendingQueries.Remove(response.QueryId);
         }
     }
 }
        public ChannelMessage Handle(ChannelMessage message)
        {
            if (message.Type() != ChannelMessageType.RpcRequest)
            {
                return(message);
            }
            var request = m_MessageEncoder.ToRequest(message);

            RpcResponse  rpcResponse  = null;
            RpcException rpcException = null;

            try
            {
                rpcResponse = m_RpcRequestHandler.Handle(request);
            }
            catch (Exception exception)
            {
                rpcException = new RpcException(request.QueryId, exception);
            }
            try
            {
                if (rpcResponse != null)
                {
                    m_RpcMessageWriter.Write(rpcResponse);
                }
                if (rpcException != null)
                {
                    m_RpcMessageWriter.Write(rpcException);
                }
            }
            catch (ChannelFaultedException)
            {
                // Other components will handle disconnection
            }

            return(null);
        }
Beispiel #3
0
 public void Write(RpcResponse response)
 {
     m_ChannelMessageWriter.Write(m_MessageEncoder.ToChannelMessage(response));
 }