@SuppressWarnings("static-access")
    void setupOutgoingCommand(OutgoingCommand command) throws EnetException
    {
        Channel channel = this.channels.get(command.command.channelID());
        this.outgoingDataTotal += command.command.length() + (command.fragmentLength & 0xFFFF);
        if (command.command.channelID() == 0xFF)
        {
            this.outgoingReliableSequenceNumber++;
            command.reliableSequenceNumber = this.outgoingReliableSequenceNumber;
            command.unreliableSequenceNumber = 0;
        }
        else if (command.command.flags().contains(Protocol.CommandFlag.Acknowledge))
        {
            channel.outgoingReliableSequenceNumber++;
            channel.outgoingUnreliableSequenceNumber = 0;
            command.reliableSequenceNumber = channel.outgoingReliableSequenceNumber;
            command.unreliableSequenceNumber = 0;
        }
        else if (command.command.flags().contains(Protocol.CommandFlag.Unsequenced))
        {
            this.outgoingUnsequencedGroup++;
            command.reliableSequenceNumber = 0;
            command.unreliableSequenceNumber = 0;
        }
        else
        {
            if (command.fragmentOffset == 0)
                channel.outgoingUnreliableSequenceNumber++;
            command.reliableSequenceNumber = channel.outgoingReliableSequenceNumber;
            command.unreliableSequenceNumber = channel.outgoingUnreliableSequenceNumber;
        }

        command.sendAttempts = 0;
        command.sentTime = 0;
        command.roundTripTimeout = 0;
        command.roundTripTimeoutLimit = 0;
        command.command.setReliableSequenceNumber(command.reliableSequenceNumber);
        
        switch (command.command.command())
        {
        case SendUnreliable:
            ((Protocol.SendUnreliable) command.command).setUnreliableSequenceNumber(command.unreliableSequenceNumber);
            break;
            
        case SendUnsequenced:
            ((Protocol.SendUnsequenced) command.command).setUnsequencedGroup(this.outgoingUnsequencedGroup);
            break;
        }
        
        if (command.command.flags().contains(Protocol.CommandFlag.Acknowledge))
            this.outgoingReliableCommands.add(command);
        else
            this.outgoingUnreliableCommands.add(command);
    }