DiscordPHP Documentation

IpcClient extends EventEmitter
in package

FinalYes

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
link
https://docs.discord.com/developers/topics/rpc
SuppressWarnings

(PHPMD.StaticAccess) Optional global-loop default and stateless wire/path utilities.

(PHPMD.TooManyMethods) Public lifecycle/command facade over focused internal units.

(PHPMD.CouplingBetweenObjects) Facade wires the focused transport, protocol and OAuth units.

since
10.69.0

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

$connecting

private ?Deferred $connecting = null

$connectTimer

private ?TimerInterface $connectTimer = null

$options

private array<string|int, mixed> $options

$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
PromiseInterface

authorize()

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
PromiseInterface

authorizeAndAuthenticate()

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
On this page

Search results