WSConnection
class WSConnection implements EventEmitterInterface (View source)
Handles the WS connection.
Traits
Properties
| WSManager | $wsmanager | ||
| int | $shardID | ||
| protected WebSocket | $ws | ||
| protected WSCompressionInterface | $compressContext | ||
| array | $ratelimits | The WS ratelimits. | |
| TimerInterface | $heartbeat | ||
| array | $wsHeartbeat | The WS heartbeat. | |
| protected bool | $authenticated | The WS authentication state. | |
| protected array | $queue | The WS queue. | |
| protected bool | $running | The WS queue processing status. | |
| protected bool | $expectedClose | If the connection gets closed, did we expect it? | |
| protected bool | $previous | Whether we should use the previous sequence for RESUME (for after compress context failure). | |
| bool | $ready | ||
| protected int | $lastPacketTime | The timestamp of when we received the last event. | |
| protected mixed|null | $previousSequence | The previous sequence. | |
| protected mixed | $sequence | The sequence. | |
| int[] | $pings | ||
| protected array | $wsCloseCodes | WS close codes, sorted by resumable session and ends everything. | |
| int | $status | ||
| protected string|null | $wsSessionID | The Discord Session ID. | |
| WSEncodingInterface | $encoding |
Methods
DO NOT initialize this class yourself.
No description
No description
Disconnects.
Connects to the gateway url. Resolves with $this.
Closes the WS connection.
Closes the WS connection.
Closes the WS connection.
No description
Processes the WS queue.
Set authenticated.
Get the session ID.
Set the session ID.
Sets the sequence.
Sends an IDENTIFY or RESUME payload, depending on ws session ID.
Sends a heartbeat.
Handles heart failures.
Handles heartbeat ack.
Direct ws send method. DO NOT USE.
Initializes the websocet.
Returns the handler for self.ready event.
Returns the handler for self.error event.
Returns the handler for message event.
Returns the handler for error event.
Returns the handler for close event.
Details
at line 166
__construct(WSManager $wsmanager, int $shardID, string $compression)
DO NOT initialize this class yourself.
at line 182
bool
__isset(string $name)
at line 199
mixed
__get(string $name)
at line 211
void
destroy()
Disconnects.
at line 220
ExtendedPromiseInterface
connect(bool $reconnect = false)
Connects to the gateway url. Resolves with $this.
at line 279
void
disconnect(int $code = 1000, string $reason = '')
Closes the WS connection.
at line 296
void
reconnect(bool $resumable = true)
Closes the WS connection.
at line 313
protected ExtendedPromiseInterface
renewConnection(bool $forceNewGateway = true)
Closes the WS connection.
at line 348
ExtendedPromiseInterface
send(array $packet)
at line 366
void
processQueue()
Processes the WS queue.
at line 397
void
setAuthenticated(bool $state)
Set authenticated.
at line 405
string|null
getSessionID()
Get the session ID.
at line 413
void
setSessionID(string|null $id)
Set the session ID.
at line 421
void
setSequence($sequence)
Sets the sequence.
at line 430
void
sendIdentify()
Sends an IDENTIFY or RESUME payload, depending on ws session ID.
at line 478
void
heartbeat()
Sends a heartbeat.
at line 502
void
heartFailure()
Handles heart failures.
at line 511
void
_pong($end)
Handles heartbeat ack.
at line 530
void
_send(array $packet)
Direct ws send method. DO NOT USE.
at line 547
protected void
initWS(WebSocket $conn, bool $ready, bool $reconnect, Deferred $deferred)
Initializes the websocet.
at line 578
protected Closure
initWSSelfReady(bool $ready, bool $reconnect, Deferred $deferred)
Returns the handler for self.ready event.
at line 599
protected Closure
initWSSelfError(bool $ready, Deferred $deferred)
Returns the handler for self.error event.
at line 614
protected Closure
initWSMessage(bool $ready, Deferred $deferred)
Returns the handler for message event.