コード例 #1
0
        public PacketReceiverKCP(NetworkInterfaceBase networkInterface) : base(networkInterface)
        {
            _buffer        = new byte[MessageLength.MaxValue + (Deps.KCP.IKCP_OVERHEAD * 2)];
            _messageReader = new MessageReaderKCP();

            kcp_ = ((NetworkInterfaceKCP)networkInterface).kcp();
        }
コード例 #2
0
        public void send(NetworkInterfaceBase networkInterface)
        {
            fini(true);

            if (networkInterface.valid())
            {
                for (int i = 0; i < streamList.Count; i++)
                {
                    MemoryStream tempStream = streamList[i];
                    networkInterface.send(tempStream);
                }
            }
            else
            {
                Dbg.ERROR_MSG("Bundle::send: networkInterface invalid!");
            }

            // 把不用的MemoryStream放回缓冲池,以减少垃圾回收的消耗
            for (int i = 0; i < streamList.Count; ++i)
            {
                streamList[i].reclaimObject();
            }

            streamList.Clear();
            stream.clear();

            // 我们认为,发送完成,就视为这个bundle不再使用了,
            // 所以我们会把它放回对象池,以减少垃圾回收带来的消耗,
            // 如果需要继续使用,应该重新Bundle.createObject(),
            // 如果外面不重新createObject()而直接使用,就可能会出现莫名的问题,
            // 仅以此备注,警示使用者。
            Bundle.reclaimObject(this);
        }
コード例 #3
0
        public PacketSenderTCP(NetworkInterfaceBase networkInterface) : base(networkInterface)
        {
            _buffer = new byte[KBEngineApp.app.getInitArgs().TCP_SEND_BUFFER_MAX];

            _wpos    = 0;
            _spos    = 0;
            _sending = false;
        }
コード例 #4
0
 public PacketSenderKCP(NetworkInterfaceBase networkInterface) : base(networkInterface)
 {
     socket_        = _networkInterface.sock();
     remoteEndPint_ = ((NetworkInterfaceKCP)_networkInterface).remoteEndPint;
 }
コード例 #5
0
 public PacketReceiverTCP(NetworkInterfaceBase networkInterface) : base(networkInterface)
 {
     _buffer        = new byte[KBEngineApp.app.getInitArgs().TCP_RECV_BUFFER_MAX];
     _messageReader = new MessageReaderTCP();
 }
コード例 #6
0
 public PacketReceiverBase(NetworkInterfaceBase networkInterface)
 {
     _networkInterface = networkInterface;
 }
コード例 #7
0
 public PacketSenderBase(NetworkInterfaceBase networkInterface)
 {
     _networkInterface = networkInterface;
     _asyncSendMethod  = new AsyncSendMethod(this._asyncSend);
     _asyncCallback    = new AsyncCallback(_onSent);
 }