Example #1
0
        private void DispatchMessage(TcpProtocolDtoBase data, ICommunicationChannel responseChannel)
        {
            if (!_dispatchers.TryGetValue(data.ServiceName, out var serviceRecord))
            {
                SessionLog.WriteLine("No dispatcher for " + data.ServiceName);
                return;
            }

            if (data is RpcCall rpcCall)
            {
                SessionLog.WriteLine("Processing call to " + rpcCall.Id);
                var result = serviceRecord.Dispatcher.Dispatch(serviceRecord.ServiceInstance, rpcCall.Id, rpcCall.Parameters);
                if (result != null)
                {
                    var callResult = RpcCallResult.Respond(rpcCall, result);
                    responseChannel.Write(callResult);
                }
            }
            else if (data is RpcCallResult result)
            {
                SessionLog.WriteLine("Saving response to " + result.Id);
                lock (_responses)
                {
                    _responses.Enqueue(result);
                }
                _responseAvailable.Set();
            }
        }
Example #2
0
        private void ProcessSuccess(RpcCall message, ICommunicationChannel responseChannel)
        {
            RpcCallResult callResult = null;

            try
            {
                var methodResult = _requestProcessor.Dispatch(_requestService, message.Id, message.Parameters);
                if (methodResult != null)
                {
                    callResult = RpcCallResult.Respond(message, methodResult);
                }
            }
            catch (Exception e)
            {
                callResult = RpcCallResult.Exception(message, e);
            }

            if (callResult != null)
            {
                responseChannel.Write(callResult);
            }
        }
Example #3
0
        public void ThreadStopped(int threadId, ThreadStopReason reason)
        {
            var dto = RpcCall.Create(nameof(IDebugEventListener), nameof(ThreadStopped), threadId, reason);

            _channel.Write(dto);
        }