public ChannelMessage Handle(ChannelMessage message) { switch (message.Type()) { case ChannelMessageType.RpcResponse: var response = m_MessageEncoder.ToResponse(message); m_RpcMessageBroker.HandleInbound(response); return(null); // Handled case ChannelMessageType.RpcException: var exception = m_MessageEncoder.ToException(message); m_RpcMessageBroker.HandleInbound(exception); return(null); // Handled default: return(message); // Not handled } }
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); }