예제 #1
0
        private void ProcessReceive(UInt32 current)
        {
            while (rcvQueue.Count > 0)
            {
                var data = rcvQueue.Dequeue();
                int r    = KCP.KcpInput(kcp, data, 0, data.Length);

                if (r < 0)
                {
                    Logger.Log("[user-{0}] input error, r:{1}", user, r);
                    break;
                }

                var size = KCP.KcpPeeksize(kcp);
                if (size > 0)
                {
                    r = KCP.KcpRecv(kcp, kcpRcvBuf, kcpRcvBuf.Length);
                    if (r <= 0)
                    {
                        break;
                    }
                    rcvCallback(kcpRcvBuf, size, user);
                }
                else
                {
                    Logger.Log("[user-{0}] peek error, r:{1}", user, size);
                    break;
                }
            }
        }