示例#1
0
    private void ProcessAcknowledgePacket(Stream stream)
    {
        Debug.Log("I received acknowledge packet");

        ReliableAcknowledgePacket packet = new ReliableAcknowledgePacket();

        packet.Deserialize(stream);

        for (int i = 0; i <= packet.lastAck; i++)
        {
            uint aux = packet.ackBits & (1u << i);

            uint id = packet.lastAck - (uint)i;

            if (aux != 0)
            {
                if (packetsAwaitingAcknowledge.ContainsKey(id))
                {
                    packetsAwaitingAcknowledge.Remove(id);
                }
            }
            else
            {
                ResendReliablePacket(id);
            }
        }
    }
示例#2
0
    private void SendAcknowledgePacket(uint senderId)
    {
        ReliableAcknowledgePacket packet = new ReliableAcknowledgePacket();

        if (NetworkManager.instance.IsServer)
        {
            packet.lastAck = lastAckPerClient[senderId];
            packet.ackBits = ackBitsPerClient[senderId];
            SendReliablePacket(packet, 2, NetworkManager.instance.GetClientIpById(senderId));
        }
        else
        {
            packet.lastAck = lastServerAck;
            packet.ackBits = serverAckBits;
            SendReliablePacket(packet, 2);
        }
    }