private void InitBuf() { if (m_Buf == null) { m_Buf = NetByteArrayPool.GetBuffer(1); m_DataSize = 0; } }
public NetManager() { m_Client = new ClientSocket(); m_Client.AddStateEvent(OnSocketStateEvent); m_Timer = TimerMgr.Instance.CreateTimer(0, true); m_Timer.AddListener(OnTimerEvent); NetByteArrayPool.InitMgr(); }
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(); }
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; } }
public void Dispose() { NetByteArrayPool._DestroyBuffer(this); }