コード例 #1
0
 public bool SendInternalBuffer()
 {
     NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Outgoing, 0x1d, "msg", 1);
     if (!this.m_IsReliable || (this.m_PendingPackets.Count <= 0))
     {
         return(this.m_CurrentPacket.SendToTransport(this.m_Connection, this.m_ChannelId));
     }
     while (this.m_PendingPackets.Count > 0)
     {
         ChannelPacket packet = this.m_PendingPackets[0];
         if (!packet.SendToTransport(this.m_Connection, this.m_ChannelId))
         {
             break;
         }
         pendingPacketCount--;
         this.m_PendingPackets.RemoveAt(0);
         FreePacket(packet);
         if (this.m_IsBroken && (this.m_PendingPackets.Count < (this.m_MaxPendingPacketCount / 2)))
         {
             if (LogFilter.logWarn)
             {
                 Debug.LogWarning("ChannelBuffer recovered from overflow but data was lost.");
             }
             this.m_IsBroken = false;
         }
     }
     return(true);
 }
コード例 #2
0
ファイル: ChannelBuffer.cs プロジェクト: Hengle/JellyTerain
 private static void FreePacket(ChannelPacket packet)
 {
     if (s_FreePackets.Count < 512)
     {
         s_FreePackets.Add(packet);
     }
 }
コード例 #3
0
 public bool SendInternalBuffer()
 {
     NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Outgoing, (short)29, "msg", 1);
     if (!this.m_IsReliable || this.m_PendingPackets.Count <= 0)
     {
         return(this.m_CurrentPacket.SendToTransport(this.m_Connection, (int)this.m_ChannelId));
     }
     while (this.m_PendingPackets.Count > 0)
     {
         ChannelPacket packet = this.m_PendingPackets.Dequeue();
         if (!packet.SendToTransport(this.m_Connection, (int)this.m_ChannelId))
         {
             this.m_PendingPackets.Enqueue(packet);
             break;
         }
         --ChannelBuffer.pendingPacketCount;
         ChannelBuffer.FreePacket(packet);
         if (this.m_IsBroken && this.m_PendingPackets.Count < this.m_MaxPendingPacketCount / 2)
         {
             if (LogFilter.logWarn)
             {
                 Debug.LogWarning((object)"ChannelBuffer recovered from overflow but data was lost.");
             }
             this.m_IsBroken = false;
         }
     }
     return(true);
 }
コード例 #4
0
 public bool SendInternalBuffer()
 {
     if (this.m_IsReliable && this.m_PendingPackets.Count > 0)
     {
         while (this.m_PendingPackets.Count > 0)
         {
             ChannelPacket packet = this.m_PendingPackets[0];
             if (!packet.SendToTransport(this.m_Connection, (int)this.m_ChannelId))
             {
                 break;
             }
             ChannelBuffer.pendingPacketCount--;
             this.m_PendingPackets.RemoveAt(0);
             ChannelBuffer.FreePacket(packet);
             if (this.m_IsBroken && this.m_PendingPackets.Count < this.m_MaxPendingPacketCount / 2)
             {
                 if (LogFilter.logWarn)
                 {
                     Debug.LogWarning("ChannelBuffer recovered from overflow but data was lost.");
                 }
                 this.m_IsBroken = false;
             }
         }
         return(true);
     }
     return(this.m_CurrentPacket.SendToTransport(this.m_Connection, (int)this.m_ChannelId));
 }
コード例 #5
0
        public bool SendInternalBuffer()
        {
            bool result;

            if (this.m_IsReliable && this.m_PendingPackets.Count > 0)
            {
                while (this.m_PendingPackets.Count > 0)
                {
                    ChannelPacket channelPacket = this.m_PendingPackets.Dequeue();
                    if (!channelPacket.SendToTransport(this.m_Connection, (int)this.m_ChannelId))
                    {
                        this.m_PendingPackets.Enqueue(channelPacket);
                        break;
                    }
                    ChannelBuffer.pendingPacketCount--;
                    ChannelBuffer.FreePacket(channelPacket);
                    if (this.m_IsBroken && this.m_PendingPackets.Count < this.m_MaxPendingPacketCount / 2)
                    {
                        if (LogFilter.logWarn)
                        {
                            Debug.LogWarning("ChannelBuffer recovered from overflow but data was lost.");
                        }
                        this.m_IsBroken = false;
                    }
                }
                result = true;
            }
            else
            {
                result = this.m_CurrentPacket.SendToTransport(this.m_Connection, (int)this.m_ChannelId);
            }
            return(result);
        }
コード例 #6
0
        protected virtual void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!m_Disposed)
            {
                if (disposing)
                {
                    if (m_PendingPackets != null)
                    {
                        while (m_PendingPackets.Count > 0)
                        {
                            pendingPacketCount -= 1;

                            ChannelPacket packet = m_PendingPackets.Dequeue();
                            if (s_FreePackets.Count < k_MaxFreePacketCount)
                            {
                                s_FreePackets.Add(packet);
                            }
                        }
                        m_PendingPackets.Clear();
                    }
                }
            }
            m_Disposed = true;
        }
コード例 #7
0
ファイル: ChannelBuffer.cs プロジェクト: Hengle/JellyTerain
 public bool SendInternalBuffer()
 {
     if (m_IsReliable && m_PendingPackets.Count > 0)
     {
         while (m_PendingPackets.Count > 0)
         {
             ChannelPacket channelPacket = m_PendingPackets.Dequeue();
             if (!channelPacket.SendToTransport(m_Connection, m_ChannelId))
             {
                 m_PendingPackets.Enqueue(channelPacket);
                 break;
             }
             pendingPacketCount--;
             FreePacket(channelPacket);
             if (m_IsBroken && m_PendingPackets.Count < m_MaxPendingPacketCount / 2)
             {
                 if (LogFilter.logWarn)
                 {
                     Debug.LogWarning("ChannelBuffer recovered from overflow but data was lost.");
                 }
                 m_IsBroken = false;
             }
         }
         return(true);
     }
     return(m_CurrentPacket.SendToTransport(m_Connection, m_ChannelId));
 }
コード例 #8
0
 private static void FreePacket(ChannelPacket packet)
 {
     if (ChannelBuffer.s_FreePackets.Count >= 512)
     {
         return;
     }
     ChannelBuffer.s_FreePackets.Add(packet);
 }
コード例 #9
0
 private static void FreePacket(ChannelPacket packet)
 {
     NetworkDetailStats.SetStat(NetworkDetailStats.NetworkDirection.Outgoing, 0x1f, "msg", pendingPacketCount);
     if (s_FreePackets.Count < 0x200)
     {
         s_FreePackets.Add(packet);
     }
 }
コード例 #10
0
 private static void FreePacket(ChannelPacket packet)
 {
     NetworkDetailStats.SetStat(NetworkDetailStats.NetworkDirection.Outgoing, (short)31, "msg", ChannelBuffer.pendingPacketCount);
     if (ChannelBuffer.s_FreePackets.Count >= 512)
     {
         return;
     }
     ChannelBuffer.s_FreePackets.Add(packet);
 }
コード例 #11
0
 static void FreePacket(ChannelPacket packet)
 {
     if (s_FreePackets.Count >= k_MaxFreePacketCount)
     {
         // just discard this packet, already tracking too many free packets
         return;
     }
     s_FreePackets.Add(packet);
 }
コード例 #12
0
ファイル: ChannelBuffer.cs プロジェクト: Hengle/JellyTerain
        public bool SetOption(ChannelOption option, int value)
        {
            switch (option)
            {
            case ChannelOption.MaxPendingBuffers:
                if (!m_IsReliable)
                {
                    return(false);
                }
                if (value < 0 || value >= 512)
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("Invalid MaxPendingBuffers for channel " + m_ChannelId + ". Must be greater than zero and less than " + 512);
                    }
                    return(false);
                }
                m_MaxPendingPacketCount = value;
                return(true);

            case ChannelOption.AllowFragmentation:
                m_AllowFragmentation = (value != 0);
                return(true);

            case ChannelOption.MaxPacketSize:
                if (!m_CurrentPacket.IsEmpty() || m_PendingPackets.Count > 0)
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("Cannot set MaxPacketSize after sending data.");
                    }
                    return(false);
                }
                if (value <= 0)
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("Cannot set MaxPacketSize less than one.");
                    }
                    return(false);
                }
                if (value > m_MaxPacketSize)
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("Cannot set MaxPacketSize to greater than the existing maximum (" + m_MaxPacketSize + ").");
                    }
                    return(false);
                }
                m_CurrentPacket = new ChannelPacket(value, m_IsReliable);
                m_MaxPacketSize = value;
                return(true);

            default:
                return(false);
            }
        }
コード例 #13
0
        private ChannelPacket AllocPacket()
        {
            if (ChannelBuffer.s_FreePackets.Count == 0)
            {
                return(new ChannelPacket(this.m_MaxPacketSize, this.m_IsReliable));
            }
            ChannelPacket result = ChannelBuffer.s_FreePackets[0];

            ChannelBuffer.s_FreePackets.RemoveAt(0);
            result.Reset();
            return(result);
        }
コード例 #14
0
ファイル: ChannelBuffer.cs プロジェクト: Hengle/JellyTerain
        private ChannelPacket AllocPacket()
        {
            if (s_FreePackets.Count == 0)
            {
                return(new ChannelPacket(m_MaxPacketSize, m_IsReliable));
            }
            ChannelPacket result = s_FreePackets[s_FreePackets.Count - 1];

            s_FreePackets.RemoveAt(s_FreePackets.Count - 1);
            result.Reset();
            return(result);
        }
コード例 #15
0
        static void FreePacket(ChannelPacket packet)
        {
#if UNITY_EDITOR
            Profiler.SetStatOutgoing(MsgType.HLAPIPending, pendingPacketCount);
#endif
            if (s_FreePackets.Count >= k_MaxFreePacketCount)
            {
                // just discard this packet, already tracking too many free packets
                return;
            }
            s_FreePackets.Add(packet);
        }
コード例 #16
0
        private ChannelPacket AllocPacket()
        {
            NetworkDetailStats.SetStat(NetworkDetailStats.NetworkDirection.Outgoing, (short)31, "msg", ChannelBuffer.pendingPacketCount);
            if (ChannelBuffer.s_FreePackets.Count == 0)
            {
                return(new ChannelPacket(this.m_MaxPacketSize, this.m_IsReliable));
            }
            ChannelPacket freePacket = ChannelBuffer.s_FreePackets[ChannelBuffer.s_FreePackets.Count - 1];

            ChannelBuffer.s_FreePackets.RemoveAt(ChannelBuffer.s_FreePackets.Count - 1);
            freePacket.Reset();
            return(freePacket);
        }
コード例 #17
0
        private ChannelPacket AllocPacket()
        {
            NetworkDetailStats.SetStat(NetworkDetailStats.NetworkDirection.Outgoing, 0x1f, "msg", pendingPacketCount);
            if (s_FreePackets.Count == 0)
            {
                return(new ChannelPacket(this.m_MaxPacketSize, this.m_IsReliable));
            }
            ChannelPacket packet = s_FreePackets[0];

            s_FreePackets.RemoveAt(0);
            packet.Reset();
            return(packet);
        }
コード例 #18
0
 static void FreePacket(ChannelPacket packet)
 {
     #if UNITY_EDITOR
     UnityEditor.NetworkDetailStats.SetStat(
         UnityEditor.NetworkDetailStats.NetworkDirection.Outgoing,
         MsgType.HLAPIPending, "msg", pendingPacketCount);
     #endif
     if (s_FreePackets.Count >= k_MaxFreePacketCount)
     {
         // just discard this packet, already tracking too many free packets
         return;
     }
     s_FreePackets.Add(packet);
 }
コード例 #19
0
 public ChannelBuffer(NetworkConnection conn, int bufferSize, byte cid, bool isReliable)
 {
   this.m_Connection = conn;
   this.m_MaxPacketSize = bufferSize - 100;
   this.m_CurrentPacket = new ChannelPacket(this.m_MaxPacketSize, isReliable);
   this.m_ChannelId = cid;
   this.m_MaxPendingPacketCount = 16;
   this.m_IsReliable = isReliable;
   if (!isReliable)
     return;
   this.m_PendingPackets = new Queue<ChannelPacket>();
   if (ChannelBuffer.s_FreePackets != null)
     return;
   ChannelBuffer.s_FreePackets = new List<ChannelPacket>();
 }
コード例 #20
0
ファイル: ChannelBuffer.cs プロジェクト: randomize/VimConfig
 public ChannelBuffer(NetworkConnection conn, int bufferSize, byte cid, bool isReliable)
 {
     this.m_Connection = conn;
     this.m_MaxPacketSize = bufferSize - 100;
     this.m_CurrentPacket = new ChannelPacket(this.m_MaxPacketSize, isReliable);
     this.m_ChannelId = cid;
     this.m_MaxPendingPacketCount = 0x10;
     this.m_IsReliable = isReliable;
     if (isReliable)
     {
         this.m_PendingPackets = new List<ChannelPacket>();
         if (s_FreePackets == null)
         {
             s_FreePackets = new List<ChannelPacket>();
         }
     }
 }
コード例 #21
0
        private ChannelPacket AllocPacket()
        {
            ChannelPacket result;

            if (ChannelBuffer.s_FreePackets.Count == 0)
            {
                result = new ChannelPacket(this.m_MaxPacketSize, this.m_IsReliable);
            }
            else
            {
                ChannelPacket channelPacket = ChannelBuffer.s_FreePackets[ChannelBuffer.s_FreePackets.Count - 1];
                ChannelBuffer.s_FreePackets.RemoveAt(ChannelBuffer.s_FreePackets.Count - 1);
                channelPacket.Reset();
                result = channelPacket;
            }
            return(result);
        }
コード例 #22
0
ファイル: ChannelBuffer.cs プロジェクト: Hengle/JellyTerain
 protected virtual void Dispose(bool disposing)
 {
     if (!m_Disposed && disposing && m_PendingPackets != null)
     {
         while (m_PendingPackets.Count > 0)
         {
             pendingPacketCount--;
             ChannelPacket item = m_PendingPackets.Dequeue();
             if (s_FreePackets.Count < 512)
             {
                 s_FreePackets.Add(item);
             }
         }
         m_PendingPackets.Clear();
     }
     m_Disposed = true;
 }
コード例 #23
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this.m_Disposed && disposing && this.m_PendingPackets != null)
     {
         while (this.m_PendingPackets.Count > 0)
         {
             --ChannelBuffer.pendingPacketCount;
             ChannelPacket channelPacket = this.m_PendingPackets.Dequeue();
             if (ChannelBuffer.s_FreePackets.Count < 512)
             {
                 ChannelBuffer.s_FreePackets.Add(channelPacket);
             }
         }
         this.m_PendingPackets.Clear();
     }
     this.m_Disposed = true;
 }
コード例 #24
0
 public ChannelBuffer(NetworkConnection conn, int bufferSize, byte cid, bool isReliable)
 {
     m_Connection            = conn;
     m_MaxPacketSize         = bufferSize - 100;
     m_CurrentPacket         = new ChannelPacket(m_MaxPacketSize, isReliable);
     m_ChannelId             = cid;
     m_MaxPendingPacketCount = 16;
     m_IsReliable            = isReliable;
     if (isReliable)
     {
         m_PendingPackets = new List <ChannelPacket>();
         if (s_FreePackets == null)
         {
             s_FreePackets = new List <ChannelPacket>();
         }
     }
 }
コード例 #25
0
 public ChannelBuffer(NetworkConnection conn, int bufferSize, byte cid, bool isReliable, bool isSequenced)
 {
     this.m_Connection            = conn;
     this.m_MaxPacketSize         = bufferSize - 100;
     this.m_CurrentPacket         = new ChannelPacket(this.m_MaxPacketSize, isReliable);
     this.m_ChannelId             = cid;
     this.m_MaxPendingPacketCount = 16;
     this.m_IsReliable            = isReliable;
     this.m_AllowFragmentation    = (isReliable && isSequenced);
     if (isReliable)
     {
         this.m_PendingPackets = new Queue <ChannelPacket>();
         if (ChannelBuffer.s_FreePackets == null)
         {
             ChannelBuffer.s_FreePackets = new List <ChannelPacket>();
         }
     }
 }
コード例 #26
0
        public ChannelBuffer(NetworkConnection conn, int bufferSize, byte cid, bool isReliable, bool isSequenced)
        {
            m_Connection    = conn;
            m_MaxPacketSize = bufferSize - k_PacketHeaderReserveSize;
            m_CurrentPacket = new ChannelPacket(m_MaxPacketSize, isReliable);

            m_ChannelId             = cid;
            m_MaxPendingPacketCount = MaxPendingPacketCount;
            m_IsReliable            = isReliable;
            m_AllowFragmentation    = (isReliable && isSequenced);
            if (isReliable)
            {
                m_PendingPackets = new Queue <ChannelPacket>();
                if (s_FreePackets == null)
                {
                    s_FreePackets = new List <ChannelPacket>();
                }
            }
        }
コード例 #27
0
 public ChannelBuffer(NetworkConnection conn, int bufferSize, byte cid, bool isReliable)
 {
     this.m_Connection            = conn;
     this.m_MaxPacketSize         = bufferSize - 100;
     this.m_CurrentPacket         = new ChannelPacket(this.m_MaxPacketSize, isReliable);
     this.m_ChannelId             = cid;
     this.m_MaxPendingPacketCount = 16;
     this.m_IsReliable            = isReliable;
     if (!isReliable)
     {
         return;
     }
     this.m_PendingPackets = new Queue <ChannelPacket>();
     if (ChannelBuffer.s_FreePackets != null)
     {
         return;
     }
     ChannelBuffer.s_FreePackets = new List <ChannelPacket>();
 }
コード例 #28
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this.m_Disposed)
     {
         if (disposing)
         {
             if (this.m_PendingPackets != null)
             {
                 while (this.m_PendingPackets.Count > 0)
                 {
                     ChannelBuffer.pendingPacketCount--;
                     ChannelPacket item = this.m_PendingPackets.Dequeue();
                     if (ChannelBuffer.s_FreePackets.Count < 512)
                     {
                         ChannelBuffer.s_FreePackets.Add(item);
                     }
                 }
                 this.m_PendingPackets.Clear();
             }
         }
     }
     this.m_Disposed = true;
 }
コード例 #29
0
 private void QueuePacket()
 {
   ++ChannelBuffer.pendingPacketCount;
   this.m_PendingPackets.Enqueue(this.m_CurrentPacket);
   this.m_CurrentPacket = this.AllocPacket();
 }
コード例 #30
0
ファイル: ChannelBuffer.cs プロジェクト: Hengle/JellyTerain
 private void QueuePacket()
 {
     pendingPacketCount++;
     m_PendingPackets.Enqueue(m_CurrentPacket);
     m_CurrentPacket = AllocPacket();
 }
コード例 #31
0
ファイル: ChannelBuffer.cs プロジェクト: randomize/VimConfig
 private static void FreePacket(ChannelPacket packet)
 {
     NetworkDetailStats.SetStat(NetworkDetailStats.NetworkDirection.Outgoing, 0x1f, "msg", pendingPacketCount);
     if (s_FreePackets.Count < 0x200)
     {
         s_FreePackets.Add(packet);
     }
 }
コード例 #32
0
 private void QueuePacket()
 {
     pendingPacketCount++;
     this.m_PendingPackets.Add(this.m_CurrentPacket);
     this.m_CurrentPacket = this.AllocPacket();
 }
コード例 #33
0
        public bool SetOption(ChannelOption option, int value)
        {
            switch (option)
            {
            case ChannelOption.MaxPendingBuffers:
            {
                if (!m_IsReliable)
                {
                    // not an error
                    //if (LogFilter.logError) { Debug.LogError("Cannot set MaxPendingBuffers on unreliable channel " + m_ChannelId); }
                    return(false);
                }
                if (value < 0 || value >= MaxBufferedPackets)
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("Invalid MaxPendingBuffers for channel " + m_ChannelId + ". Must be greater than zero and less than " + k_MaxFreePacketCount);
                    }
                    return(false);
                }
                m_MaxPendingPacketCount = value;
                return(true);
            }

            case ChannelOption.AllowFragmentation:
            {
                m_AllowFragmentation = (value != 0);
                return(true);
            }

            case ChannelOption.MaxPacketSize:
            {
                if (!m_CurrentPacket.IsEmpty() || m_PendingPackets.Count > 0)
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("Cannot set MaxPacketSize after sending data.");
                    }
                    return(false);
                }

                if (value <= 0)
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("Cannot set MaxPacketSize less than one.");
                    }
                    return(false);
                }

                if (value > m_MaxPacketSize)
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("Cannot set MaxPacketSize to greater than the existing maximum (" + m_MaxPacketSize + ").");
                    }
                    return(false);
                }
                // rebuild the packet with the new size. the packets doesn't store a size variable, just has the size of the internal buffer
                m_CurrentPacket = new ChannelPacket(value, m_IsReliable);
                m_MaxPacketSize = value;
                return(true);
            }
            }
            return(false);
        }
コード例 #34
0
 private static void FreePacket(ChannelPacket packet)
 {
   NetworkDetailStats.SetStat(NetworkDetailStats.NetworkDirection.Outgoing, (short) 31, "msg", ChannelBuffer.pendingPacketCount);
   if (ChannelBuffer.s_FreePackets.Count >= 512)
     return;
   ChannelBuffer.s_FreePackets.Add(packet);
 }
コード例 #35
0
 private void QueuePacket()
 {
     ++ChannelBuffer.pendingPacketCount;
     this.m_PendingPackets.Enqueue(this.m_CurrentPacket);
     this.m_CurrentPacket = this.AllocPacket();
 }
コード例 #36
0
ファイル: ChannelBuffer.cs プロジェクト: randomize/VimConfig
 private void QueuePacket()
 {
     pendingPacketCount++;
     this.m_PendingPackets.Add(this.m_CurrentPacket);
     this.m_CurrentPacket = this.AllocPacket();
 }