Nexus API Reference

WebSocketChannelActor
in package
implements StatefulActorHandler

AbstractYes
Tags
psalm-api

Per-key channel actor base. Translates internal Channel*** messages into typed onOpened/onMessage/onClosed hooks. Maintains a connection set the subclass can broadcast over via the protected helpers.

template

S

implements

StatefulActorHandler<object, S>

Table of Contents

Interfaces

StatefulActorHandler

Methods

handle()  : BehaviorWithState<object, S>
Handle an incoming message with the current state.
handleAppMessage()  : BehaviorWithState<object, S>
Hook for messages that are not lifecycle events — typically replies from actors this channel commands. Default is a no-op; override to cache state or broadcast to attached connections.
initialState()  : S
Provide the initial state for this actor.
onClosed()  : BehaviorWithState<object, S>
onMessage()  : BehaviorWithState<object, S>
onOpened()  : BehaviorWithState<object, S>
broadcast()  : void
connection()  : WebSocketContext|null
Return the live context for a single attached connection, or `null` if that fd is not (or no longer) attached. Use this to reply to the one connection that triggered a message — e.g. a private welcome or a per-client error — instead of broadcasting to the whole channel.
connections()  : array<int, WebSocketContext>

Methods

handleAppMessage()

Hook for messages that are not lifecycle events — typically replies from actors this channel commands. Default is a no-op; override to cache state or broadcast to attached connections.

public handleAppMessage(ActorContext<string|int, object> $ctx, object $message, S $state) : BehaviorWithState<object, S>
Parameters
$ctx : ActorContext<string|int, object>
$message : object
$state : S
Return values
BehaviorWithState<object, S>

initialState()

Provide the initial state for this actor.

public abstract initialState() : S
Return values
S

broadcast()

protected final broadcast(string $text[, int|null $exceptFd = null ]) : void
Parameters
$text : string
$exceptFd : int|null = null

connection()

Return the live context for a single attached connection, or `null` if that fd is not (or no longer) attached. Use this to reply to the one connection that triggered a message — e.g. a private welcome or a per-client error — instead of broadcasting to the whole channel.

protected final connection(int $fd) : WebSocketContext|null
Parameters
$fd : int
Return values
WebSocketContext|null

        
On this page

Search results