-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rework reconnecting/resuming * Privatize stopping automatic heartbeats * Add testing + refactors * cs * Restore meta & raw eventer getters * Stop awaiting heartbeat at disconnect * Add handling for undocumented 1006 * Change error messages to reflect reality more accurately
- Loading branch information
Showing
23 changed files
with
543 additions
and
778 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Fakes\Ragnarok\Fenrir; | ||
|
||
use Exan\Retrier\Retrier; | ||
use React\Promise\ExtendedPromiseInterface; | ||
|
||
class RetrierFake extends Retrier | ||
{ | ||
public function retry(int $attempts, callable $action): ExtendedPromiseInterface | ||
{ | ||
return PromiseFake::get($action(1)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Fakes\Ragnarok\Fenrir; | ||
|
||
use Evenement\EventEmitter; | ||
use JsonSerializable; | ||
use Ragnarok\Fenrir\WebsocketInterface; | ||
use React\Promise\ExtendedPromiseInterface; | ||
|
||
class WebsocketFake extends EventEmitter implements WebsocketInterface | ||
{ | ||
public array $openings = []; | ||
|
||
public function open(string $url): ExtendedPromiseInterface | ||
{ | ||
$this->openings[] = $url; | ||
|
||
return PromiseFake::get(); | ||
} | ||
|
||
public function close(int $code, string $reason): void | ||
{ | ||
} | ||
|
||
public function send(string $message, bool $useBucket = true): void | ||
{ | ||
} | ||
|
||
public function sendAsJson(array|JsonSerializable $item, bool $useBucket): void | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ragnarok\Fenrir\Constants; | ||
|
||
class GatewayCloseCodes | ||
{ | ||
final public const LIB_INSTANTIATED_RECONNECT = 1001; | ||
final public const LIB_INSTANTIATED_RESUME = 1003; | ||
|
||
final public const DESCRIPTIONS = [ | ||
1001 => 'Library instantiated: Reconnect required', | ||
1003 => 'Library instantiated: Resume required', | ||
|
||
1006 => 'Underlying connection closed', | ||
4000 => 'Unknown error', | ||
4001 => 'Unknown opcode', | ||
4002 => 'Decode error', | ||
4003 => 'Not authenticated', | ||
4004 => 'Authentication failed', | ||
4005 => 'Already authenticated', | ||
4007 => 'Invalid sequence', | ||
4008 => 'Rate limited', | ||
4009 => 'Session timed out', | ||
4010 => 'Invalid shard', | ||
4011 => 'Sharding required', | ||
4012 => 'Invalid API version', | ||
4013 => 'Invalid intents', | ||
4015 => 'Disallowed intents', | ||
]; | ||
|
||
final public const USER_ERROR = [ | ||
1001 => false, | ||
1003 => false, | ||
|
||
1006 => false, | ||
4000 => true, | ||
4001 => false, | ||
4002 => false, | ||
4003 => false, | ||
4004 => true, | ||
4005 => false, | ||
4007 => false, | ||
4008 => false, | ||
4009 => false, | ||
4010 => true, | ||
4011 => true, | ||
4012 => false, | ||
4013 => true, | ||
4014 => true, | ||
]; | ||
|
||
final public const RECOVERABLE = [ | ||
1001 => true, | ||
1003 => true, | ||
|
||
1006 => true, | ||
4000 => true, | ||
4001 => true, | ||
4002 => true, | ||
4003 => true, | ||
4004 => false, | ||
4005 => true, | ||
4007 => true, | ||
4008 => true, | ||
4009 => true, | ||
4010 => false, | ||
4011 => false, | ||
4012 => false, | ||
4013 => false, | ||
4014 => false, | ||
]; | ||
|
||
final public const RESUMABLE = [ | ||
1001 => false, | ||
1003 => true, | ||
|
||
1006 => false, | ||
4000 => true, | ||
4001 => true, | ||
4002 => true, | ||
4003 => false, | ||
4004 => false, | ||
4005 => true, | ||
4007 => false, | ||
4008 => true, | ||
4009 => false, | ||
4010 => false, | ||
4011 => false, | ||
4012 => false, | ||
4013 => false, | ||
4014 => false, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ | |
class WebsocketEvents | ||
{ | ||
final public const MESSAGE = 'MESSAGE'; | ||
final public const CLOSE = 'CLOSE'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.