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); }
public void BeginRequest(RpcRequest request, RequestToken requestToken) { if (requestToken != null) { lock (m_PendingQueries) m_PendingQueries[request.QueryId] = requestToken; } try { m_RpcMessageWriter.Write(request); } catch (ObjectDisposedException) { throw new ChannelFaultedException("The connection was closed."); } }