private void HandleReplyMessage() { var responseMessage = _replyMessageQueue.Take(); if (responseMessage == null) { return; } var remotingResponse = RemotingUtil.ParseResponse(responseMessage); if (remotingResponse.Type == RemotingRequestType.Callback) { IResponseHandler responseHandler; if (_responseHandlerDict.TryGetValue(remotingResponse.RequestCode, out responseHandler)) { responseHandler.HandleResponse(remotingResponse); } } else if (remotingResponse.Type == RemotingRequestType.Async) { ResponseFuture responseFuture; if (_responseFutureDict.TryRemove(remotingResponse.Sequence, out responseFuture)) { if (responseFuture.SetResponse(remotingResponse)) { _logger.DebugFormat("Remoting response back, request code:{0}, requect sequence:{1}, time spent:{2}", responseFuture.Request.Code, responseFuture.Request.Sequence, (DateTime.Now - responseFuture.BeginTime).TotalMilliseconds); } else { _logger.ErrorFormat("Set remoting response failed, response:" + remotingResponse); } } } }
private void HandleReplyMessage() { var responseMessage = _replyMessageQueue.Take(); if (responseMessage == null) { return; } var remotingResponse = RemotingUtil.ParseResponse(responseMessage); ResponseFuture responseFuture; if (_responseFutureDict.TryRemove(remotingResponse.Sequence, out responseFuture)) { responseFuture.SetResponse(remotingResponse); _logger.DebugFormat("Remoting response back, request code:{0}, requect sequence:{1}, time spent:{2}", responseFuture.Request.Code, responseFuture.Request.Sequence, (DateTime.Now - responseFuture.BeginTime).TotalMilliseconds); } }
private void HandleResponseMessage(ITcpConnection connection, byte[] message) { if (message == null) { return; } var remotingResponse = RemotingUtil.ParseResponse(message); if (remotingResponse.RequestType == RemotingRequestType.Callback) { if (_responseHandlerDict.TryGetValue(remotingResponse.RequestCode, out IResponseHandler responseHandler)) { responseHandler.HandleResponse(remotingResponse); } else { _logger.ErrorFormat("No response handler found for remoting response, name: {0}, response: {1}", Name, remotingResponse); } } else if (remotingResponse.RequestType == RemotingRequestType.Async) { if (_responseFutureDict.TryRemove(remotingResponse.RequestSequence, out ResponseFuture responseFuture)) { if (responseFuture.SetResponse(remotingResponse)) { if (_logger.IsDebugEnabled) { _logger.DebugFormat("Remoting response back, name: {0}, request code: {1}, requect sequence: {2}, time spent: {3}", Name, responseFuture.Request.Code, responseFuture.Request.Sequence, (DateTime.Now - responseFuture.BeginTime).TotalMilliseconds); } } else { _logger.ErrorFormat("Set remoting response failed, name: {0}, response: {1}", Name, remotingResponse); } } } }