/// <summary> /// 处理接收到的消息体数据 /// </summary> private void OnProcessReceiveMessage() { try { this.IsProcessReceiveMessage = true; byte[] dataValueBytes = EncodeHelper.DecodeMessage(ref this.dataValueBytesCache); if (dataValueBytes == null) { this.IsProcessReceiveMessage = false; } else { //根据接收到的消息体数据转成一个具体的对应类型,然后才能对接收到的消息体数据做处理 SocketMessage tmpSocketMessage = EncodeHelper.DecodeMessage(dataValueBytes); LogMessage.Instance.SetLogMessage( string.Format("接收到客户端对象 [ {0} ] 发送过来的消息 [ {1} ]~", this.ClientSocket.RemoteEndPoint.ToString(), tmpSocketMessage.DataValue.ToString())); //处理完数据需要将处理好的数据回调给上层(通过委托的方式实现) this.ReceiveMessageComplete?.Invoke(this, tmpSocketMessage); //回调之后需要使用尾递归 this.OnProcessReceiveMessage(); } } catch (Exception exception) { Console.WriteLine(exception.Message + " " + exception.StackTrace); } }