/// <summary> /// 接收到请求的处理 /// </summary> /// <param name="info"></param> private void client_OnMsgReceived(byte[] info) { SocketRequest requestMsg = ByteSerializer.DeserializeByte <SocketMsgBase>(info) as SocketRequest; if (requestMsg != null) { Console.WriteLine("子系统{0}请求执行{1}方法", requestMsg.SubSystem, requestMsg.RequestMethod); SocketResponse response = new SocketResponse(); string result = string.Empty; try { result = OperationFactory.Execute(requestMsg.Parameters, requestMsg.RequestMethodType); response.Result = result; } catch (Exception ex) { response.ErrorMsg = "执行遇到异常"; } response.MethodName = requestMsg.MethodName; response.Sender = requestMsg.Target; response.SubSystem = requestMsg.SubSystem; response.Target = requestMsg.Sender; response.MsgType = TcpMsgDataType.Relay; client.Send(ByteSerializer.ObjectToByte(response)); Console.WriteLine("执行成功,已返回结果"); } }