Search in sources :

Example 1 with DATA_PACKET_0

use of org.dragonet.raknet.protocol.packet.DATA_PACKET_0 in project Dragonet-Legacy by DragonetMC.

the class Session method addToQueue.

private void addToQueue(EncapsulatedPacket pk, int flags) throws Exception {
    int priority = flags & 0b0000111;
    if (pk.needACK && pk.messageIndex != null) {
        Map<Integer, Integer> map;
        if (!this.needACK.containsKey(pk.identifierACK)) {
            this.needACK.put(pk.identifierACK, new HashMap<Integer, Integer>());
        }
        this.needACK.get(pk.identifierACK).put(pk.messageIndex, pk.messageIndex);
    }
    if (priority == RakNet.PRIORITY_IMMEDIATE) {
        //Skip queues
        DataPacket packet = new DATA_PACKET_0();
        packet.seqNumber = this.sendSeqNumber++;
        if (pk.needACK) {
            packet.packets.add(pk.clone());
            pk.needACK = false;
        } else {
            packet.packets.add(pk.toBinary());
        }
        this.sendPacket(packet);
        packet.sendTime = System.currentTimeMillis();
        this.recoveryQueue.put(packet.seqNumber, packet);
        return;
    }
    int length = this.sendQueue.length();
    if (length + pk.getTotalLength() > this.mtuSize) {
        this.sendQueue();
    }
    if (pk.needACK) {
        this.sendQueue.packets.add(pk.clone());
        pk.needACK = false;
    } else {
        this.sendQueue.packets.add(pk.toBinary());
    }
}
Also used : DATA_PACKET_0(org.dragonet.raknet.protocol.packet.DATA_PACKET_0) CLIENT_DISCONNECT_DataPacket(org.dragonet.raknet.protocol.packet.CLIENT_DISCONNECT_DataPacket) DataPacket(org.dragonet.raknet.protocol.DataPacket) PONG_DataPacket(org.dragonet.raknet.protocol.packet.PONG_DataPacket) SERVER_HANDSHAKE_DataPacket(org.dragonet.raknet.protocol.packet.SERVER_HANDSHAKE_DataPacket) CLIENT_CONNECT_DataPacket(org.dragonet.raknet.protocol.packet.CLIENT_CONNECT_DataPacket) CLIENT_HANDSHAKE_DataPacket(org.dragonet.raknet.protocol.packet.CLIENT_HANDSHAKE_DataPacket) PING_DataPacket(org.dragonet.raknet.protocol.packet.PING_DataPacket)

Aggregations

DataPacket (org.dragonet.raknet.protocol.DataPacket)1 CLIENT_CONNECT_DataPacket (org.dragonet.raknet.protocol.packet.CLIENT_CONNECT_DataPacket)1 CLIENT_DISCONNECT_DataPacket (org.dragonet.raknet.protocol.packet.CLIENT_DISCONNECT_DataPacket)1 CLIENT_HANDSHAKE_DataPacket (org.dragonet.raknet.protocol.packet.CLIENT_HANDSHAKE_DataPacket)1 DATA_PACKET_0 (org.dragonet.raknet.protocol.packet.DATA_PACKET_0)1 PING_DataPacket (org.dragonet.raknet.protocol.packet.PING_DataPacket)1 PONG_DataPacket (org.dragonet.raknet.protocol.packet.PONG_DataPacket)1 SERVER_HANDSHAKE_DataPacket (org.dragonet.raknet.protocol.packet.SERVER_HANDSHAKE_DataPacket)1