Exemplo n.º 1
0
 public void SendAll(KcpListener soc, byte[] data)
 {
     for (int i = 0; i < top; i++)
     {
         var l = buffer[i];
         if (l != null)
         {
             soc.Send(data, l.endpPoint);
         }
     }
 }
Exemplo n.º 2
0
 public virtual void Dispose()
 {
     envelope.Dispose();
     envelope = null;
     if (metaData != null)
     {
         metaData.Clear();
     }
     metaData = null;
     kcp      = null;
 }
Exemplo n.º 3
0
        /// <summary>
        /// 由kcpserver的recvThread线程管理
        /// </summary>
        public void DeleteTimeOutLink(KcpListener kcp, long now)
        {
            int c = queue.Count - 1;

            for (int i = c; i >= 0; i--)
            {
                var link = queue[i];
                if (now - link.RecvTime > KcpListener.TimeOut)
                {
                    if (link.Disconnect())
                    {
                        link.RecyclingTime = now;
                        kcp.PreRecycling(link);
                        queue.RemoveAt(i);
                    }
                }
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 运行,并为每个线程分配状态缓存
 /// </summary>
 /// <param name="listener">kcp监听器</param>
 /// <param name="threadCount">线程数</param>
 public void Run(KcpListener listener, int threadCount)
 {
     kcpListener  = listener;
     statesBuffer = new BlockBuffer <int>(8, 2048 * threadCount);
 }