/// <summary>
        /// 服务端使用的构造函数
        /// </summary>
        /// <param name="servlet"></param>
        public BinaryDataParser(HttpServlet servlet)
        {
            string strContent = servlet.getContentText();
            stream = new BinaryStream();
            mSession = SessionMgr.GetIns().CreateSession(servlet);

            stream.SetContent(Convert.FromBase64String(strContent));
        }
 /// <summary>
 /// 客户端使用的构造函数
 /// </summary>
 public BinaryDataParser()
 {
     mSession = SessionMgr.GetIns().CreateSession();
     stream = new BinaryStream();
 }
        /// <summary>
        /// 调用序列化数据:客户端将消息体序列化成字符串发送给服务器
        /// </summary>
        public byte[] SerializeMsg(Message msg)
        {
            BinaryStream bs = new BinaryStream();
            bs.DeconstructMessage();
            int nMsgCount = 1;
            bs.Write(nMsgCount);

            msg.DeconstructObj();
            byte[] msgData = msg.GetWriteBuffer();
            bs.Write(msgData);

            byte[] bySend = bs.GetWriteBuffer();

            return bySend;
        }
        // 子线程调用
        public void ParseAndAddMsg(long lSessionId)
        {
            lock (mSendLocker)
            {
                BinaryStream bs = new BinaryStream();
                bs.DeconstructMessage();
                int nMsgCount = mSendMsgs.Count;
                bs.Write(nMsgCount);
                for (int i = 0; i < nMsgCount; ++i)
                {
                    Message msg = mSendMsgs.Dequeue();
                    msg.DeconstructObj();
                    bs.Write(msg.GetWriteBuffer());
                }

                RespondObj resObj = new RespondObj();
                resObj.SessionId = lSessionId;
                resObj.RespondString = Convert.ToBase64String(bs.GetWriteBuffer());
                // 加入到待发送列表即可
                MsgHandler.GetIns().AddRespondMsg(resObj);
            }
        }