예제 #1
0
        internal void Flush()
        {
            if (m_Dispose)
            {
                return;
            }

            m_Kcp.Flush();
        }
예제 #2
0
 void process_kcpio_queue(object state)
 {
     while (Connected)
     {
         try
         {
             //send process
             snd_queue.DequeueAll(it =>
             {
                 SendPacket(it);
                 //mKcp.Send(it);
             });
             Stopwatch t = new Stopwatch();
             t.Start();
             mKcp.Flush((int)kcpUtil.nowTotalMilliseconds);
             rcv_queue.DequeueAll(it =>
             {
                 mKcp.Input(it);
             });
             rcvCache.Clear();
             //rcvCache.Capacity(peekSize);
             while (true)
             {
                 int peekSize = mKcp.PeekSize();
                 if (peekSize > 0)
                 {
                     int rcvSize = mKcp.Receive(rcvCache);
                     if (rcvSize > 0)
                     {
                         //packer.Recv(rcvCache);
                         Unpack(rcvCache);
                     }
                     else
                     {
                         break;
                     }
                 }
                 else
                 {
                     break;
                 }
             }
             t.Stop();
             if (t.ElapsedMilliseconds > 5)
             {
                 Console.WriteLine(string.Format("used time:{0}", t.ElapsedMilliseconds));
             }
         }
         catch (Exception e)
         {
             Console.WriteLine(e.ToString());
         }
         finally
         {
             //Console.WriteLine("thread run error");
         }
         if (kcpThreadNotify.WaitOne(5))
         {
             Thread.Sleep(2);
         }
     }
 }