Exemple #1
0
 private void InitBuf()
 {
     if (m_Buf == null)
     {
         m_Buf      = NetByteArrayPool.GetBuffer(1);
         m_DataSize = 0;
     }
 }
Exemple #2
0
        public NetManager()
        {
            m_Client = new ClientSocket();
            m_Client.AddStateEvent(OnSocketStateEvent);
            m_Timer = TimerMgr.Instance.CreateTimer(0, true);
            m_Timer.AddListener(OnTimerEvent);

            NetByteArrayPool.InitMgr();
        }
Exemple #3
0
        public void SendCapnProto(CapnProtoMsg msg, int packetHandle)
        {
            ByteBufferNode node   = NetByteArrayPool.GetByteBufferNode();
            var            buffer = node.GetBuffer();

            System.IO.MemoryStream stream = new System.IO.MemoryStream(buffer);
            msg.WriteToStream(stream);
            Send(buffer, packetHandle, (int)stream.Position);
            stream.Dispose();
            node.Dispose();
        }
Exemple #4
0
 public void Init(byte[] pData, int bufSize)
 {
     if ((pData != null) && (bufSize > 0))
     {
         if (pSendData != null)
         {
             pSendData.Dispose();
         }
         pSendData = NetByteArrayPool.GetByteBufferNode(bufSize);
         Buffer.BlockCopy(pData, 0, pSendData.GetBuffer(), 0, bufSize);
     }
     else
     {
         pSendData = null;
     }
 }
Exemple #5
0
 public void Dispose()
 {
     NetByteArrayPool._DestroyBuffer(this);
 }