WebSocketChannelActor
in package
implements
StatefulActorHandler
AbstractYes
Tags
Table of Contents
Interfaces
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
handle()
Handle an incoming message with the current state.
public
final handle(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>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
SonClosed()
public
onClosed(ActorContext<string|int, object> $ctx, WebSocketContext $conn, int $code, S $state) : BehaviorWithState<object, S>
Parameters
- $ctx : ActorContext<string|int, object>
- $conn : WebSocketContext
- $code : int
- $state : S
Return values
BehaviorWithState<object, S>onMessage()
public
abstract onMessage(ActorContext<string|int, object> $ctx, WebSocketContext $conn, WebSocketFrame $frame, S $state) : BehaviorWithState<object, S>
Parameters
- $ctx : ActorContext<string|int, object>
- $conn : WebSocketContext
- $frame : WebSocketFrame
- $state : S
Return values
BehaviorWithState<object, S>onOpened()
public
onOpened(ActorContext<string|int, object> $ctx, WebSocketContext $conn, S $state) : BehaviorWithState<object, S>
Parameters
- $ctx : ActorContext<string|int, object>
- $conn : WebSocketContext
- $state : S
Return values
BehaviorWithState<object, 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|nullconnections()
protected
final connections() : array<int, WebSocketContext>