IpcClient
extends EventEmitter
in package
Optional local RPC facade, independent of the bot Gateway runtime.
connect() resolves only after READY. request() provides raw command envelopes, not typed support for every Discord RPC command. No payloads or tokens are logged. Events: ready(data, raw), dispatch(event, data, raw), error(Throwable), close(?CloseException), pong(bytes). Call close() to release owned resources.
Tags
Table of Contents
Properties
- $authentication : ?OAuthFlow
- $clientId : string
- $connecting : ?Deferred
- $connectTimer : ?TimerInterface
- $generation : int
- $loop : LoopInterface
- $options : array<string|int, mixed>
- $outbound : OutboundQueue
- $pending : PendingRequests
- $session : IpcSession
- $state : string
Methods
- __construct() : mixed
- Windows requires an injected asynchronous native pipe connector. See guide/rpc.rst for options.
- authenticate() : PromiseInterface
- authorize() : PromiseInterface
- authorizeAndAuthenticate() : PromiseInterface<string|int, array<string|int, mixed>>
- close() : void
- Explicit close; reconnect requires a new connect() call. No automatic replay or retry.
- connect() : PromiseInterface<string|int, self>
- getCandidatePaths() : array<string|int, string>
- request() : PromiseInterface<string|int, array<string|int, mixed>>
- Raw command API. Callers own command-specific arguments, scopes and result shapes.
- sendPing() : void
- disconnect() : void
- handshake() : void
- ready() : void
- receive() : void
Properties
$authentication
private
?OAuthFlow
$authentication
= null
$clientId
private
string
$clientId
= ''
$connecting
private
?Deferred
$connecting
= null
$connectTimer
private
?TimerInterface
$connectTimer
= null
$generation
private
int
$generation
= 0
$loop
private
LoopInterface
$loop
$options
private
array<string|int, mixed>
$options
$outbound
private
OutboundQueue
$outbound
$pending
private
PendingRequests
$pending
$session
private
IpcSession
$session
$state
private
string
$state
= 'disconnected'
Methods
__construct()
Windows requires an injected asynchronous native pipe connector. See guide/rpc.rst for options.
public
__construct([?LoopInterface $loop = null ][, ?ConnectorInterface $connector = null ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $loop : ?LoopInterface = null
- $connector : ?ConnectorInterface = null
- $options : array<string|int, mixed> = []
authenticate()
public
authenticate(string $accessToken[, float $timeout = 15.0 ]) : PromiseInterface
Parameters
- $accessToken : string
- $timeout : float = 15.0
Return values
PromiseInterfaceauthorize()
public
authorize([array<string|int, mixed> $scopes = ['rpc', 'identify'] ][, float $timeout = 15.0 ]) : PromiseInterface
Parameters
- $scopes : array<string|int, mixed> = ['rpc', 'identify']
- $timeout : float = 15.0
Return values
PromiseInterfaceauthorizeAndAuthenticate()
public
authorizeAndAuthenticate(array<string|int, mixed> $scopes, string $redirectUri, TokenExchangeInterface $exchange[, float $timeout = 15.0 ]) : PromiseInterface<string|int, array<string|int, mixed>>
Parameters
- $scopes : array<string|int, mixed>
- $redirectUri : string
- $exchange : TokenExchangeInterface
- $timeout : float = 15.0
Return values
PromiseInterface<string|int, array<string|int, mixed>> —AUTHENTICATE envelope after an injected async exchange.
close()
Explicit close; reconnect requires a new connect() call. No automatic replay or retry.
public
close() : void
connect()
public
connect(string $clientId[, int $version = 1 ]) : PromiseInterface<string|int, self>
Parameters
- $clientId : string
- $version : int = 1
Return values
PromiseInterface<string|int, self> —READY, rather than only an established socket.
getCandidatePaths()
public
static getCandidatePaths([?array<string|int, mixed> $environment = null ][, ?bool $windows = null ]) : array<string|int, string>
Parameters
- $environment : ?array<string|int, mixed> = null
- $windows : ?bool = null
Return values
array<string|int, string> —Local paths in documented environment-prefix/index order.
request()
Raw command API. Callers own command-specific arguments, scopes and result shapes.
public
request(string $command[, array<string|int, mixed> $args = [] ][, ?string $event = null ][, float $timeout = 15.0 ]) : PromiseInterface<string|int, array<string|int, mixed>>
Deadlines include queue time; cancelling a sent command cannot undo its effect.
Parameters
- $command : string
- $args : array<string|int, mixed> = []
- $event : ?string = null
- $timeout : float = 15.0
Return values
PromiseInterface<string|int, array<string|int, mixed>> —Complete correlated response envelope.
sendPing()
public
sendPing([string $payload = '' ]) : void
Parameters
- $payload : string = ''
disconnect()
private
disconnect(Throwable $error) : void
Parameters
- $error : Throwable
handshake()
private
handshake(ConnectionInterface $connection, int $generation) : void
Parameters
- $connection : ConnectionInterface
- $generation : int
ready()
private
ready(array<string|int, mixed> $raw) : void
Parameters
- $raw : array<string|int, mixed>
receive()
private
receive(int $opcode, string $payload) : void
Parameters
- $opcode : int
- $payload : string