public bool RecvReliablePackets(ServerChannel channel, List <Packet> packets, IChannelListener listener, ServerHeartbeatProcessing heartbeat)
        {
            while (true)
            {
                int size = channel.Recv(m_RecvBuffer, 0, m_RecvBuffer.Length);

                if (size <= 0)
                {
                    break;
                }

                if (size == 8)
                {
                    ByteReadMemory memory = new ByteReadMemory(m_RecvBuffer, 0, size);
                    uint           flag   = memory.ReadUInt();
                    uint           conv   = memory.ReadUInt();

                    if (conv == channel.Conv)
                    {
                        if (flag == KcpConstants.Flag_Connect)
                        {
                            channel.SetConnectedStatus(true);
                            if (listener != null)
                            {
                                listener.OnAddChannel(channel);
                            }
                            continue;
                        }

                        if (flag == KcpConstants.Flag_Disconnect)
                        {
                            channel.SetConnectedStatus(false);
                            if (listener != null)
                            {
                                listener.OnRemoveChannel(channel);
                            }
                            continue;
                        }

                        if (flag == KcpConstants.Flag_Heartbeat)
                        {
                            heartbeat.UpdateHeartbeat(channel, m_RecvBuffer, 0, size);
                            continue;
                        }
                    }
                }

                PacketProcessing.Recv(m_RecvBuffer, 0, size, packets);
            }

            return(packets.Count > 0);
        }
        public void RecvReliablePackets(ClientTransport transport, KcpCon kcp, List <Packet> packets, ClientHeartbeatProcessing heartbeat)
        {
            while (true)
            {
                int size = kcp.Recv(m_Buffer, 0, m_Buffer.Length);

                if (size <= 0)
                {
                    break;
                }

                if (size == 8)
                {
                    ByteReadMemory memory = new ByteReadMemory(m_Buffer, 0, 8);
                    uint           flag   = memory.ReadUInt();
                    uint           conv   = memory.ReadUInt();

                    if (conv == kcp.Conv)
                    {
                        if (flag == KcpConstants.Flag_Heartbeat)
                        {
                            heartbeat.RecvHeartbeat();
                            continue;
                        }

                        if (flag == KcpConstants.Flag_Disconnect)
                        {
                            transport.Disconnect(false, true);
                            continue;
                        }
                    }
                }

                PacketProcessing.Recv(m_Buffer, 0, size, packets);
            }
        }
 public void RecvUnreliablePackets(byte[] rawBuffer, int offset, int count, List <Packet> packets)
 {
     PacketProcessing.Recv(rawBuffer, offset, count, packets);
 }
 public bool RecvUnreliablePackets(byte[] rawBuffer, int offset, int count, List <Packet> packets)
 {
     PacketProcessing.Recv(rawBuffer, offset, count, packets);
     return(packets.Count > 0);
 }