Exemplo n.º 1
0
        public void Send(PackageOut pkgOut)
        {
            if (m_status != SocketStatus.Connected)
            {
                return;
            }
            try
            {
                byte[] data = pkgOut.ToByteArray();
                if (NetworkManager.instance.IsDebug)
                {
                    NetworkManager.instance.Error("pkg send now code " + pkgOut.code + " process " + Thread.CurrentThread.ManagedThreadId.ToString());
                }
                lock (this)
                {
                    sendCout++;
                }

                m_socket.BeginSend(data, 0, data.Length, SocketFlags.None, new AsyncCallback(this.SendCallback), m_socket);
            }
            catch (Exception ex)
            {
                NetworkManager.instance.Error("pkg send error: " + ex.Message);
                lock (this)
                {
                    sendCout--;
                }
            }
        }
Exemplo n.º 2
0
        public byte[] GetNextData()
        {
            PackageOut pkg = packages.Dequeue();

            return(Encode(pkg.ToByteArray()));
        }