vsTerminus / Mojo-Discord

Perl Modules that implement parts of the Discord API. Intended for Text Chat Bots.
MIT License
33 stars 10 forks source link

Reconnect WS close codes #41

Open incognico opened 3 years ago

incognico commented 3 years ago

Currently theres this:

# Prevent sending a reconnect following certain codes.
# This always requires a new session to be established if these codes are encountered.
# Not sure if 1000 and 1001 require this, but I don't think it hurts to include them.
has no_resume => ( is => 'ro', default => sub {
    {
        '4003' => 'Not Authenticated',
        '4007' => 'Invalid Sequence',
        '4009' => 'Session Timeout',
        '4010' => 'Invalid Shard',
        '4011' => 'Sharding required',
        '4012' => 'Invalid API version',
        '4013' => 'Invalid intent(s)',
        '4014' => 'Disallowed intent(s)',
        'Websocket Handshake Failed' => 'Websocket Handshake Failed'
    }
});

As we now have removed the 1xxx from no_resume, this should be adjusted a bit and split into 2 hashes, one which just disables resuming like now and one which quits the library because the error probably won't be gone after reconnecting.

New:

has no_resume => ( is => 'ro', default => sub {
    {
        '4007' => 'Invalid Sequence',
        '4009' => 'Session Timeout',
        'Websocket Handshake Failed' => 'Websocket Handshake Failed'
    }
});

has quit_on_those => ( is => 'ro', default => sub {
    {
        '4004' => 'Authentication failed',
        '4010' => 'Invalid Shard',
        '4011' => 'Sharding required',
        '4012' => 'Invalid API version',
        '4013' => 'Invalid intent(s)',
        '4014' => 'Disallowed intent(s)',
    }
});
vsTerminus commented 3 years ago

Change is made in my local copy. Testing for a few days, then I'll push when happy with it.