NAME
Thunderhorse::WebSocket - WebSocket wrapper for Thunderhorse
SYNOPSIS
async sub handle ($self, $ctx)
{
my $ws = $ctx->ws;
await $ws->accept;
await $ws->each_json(async sub ($data) {
await $ws->send_json({echo => $data});
});
}
DESCRIPTION
Thunderhorse::WebSocket is a thin wrapper around PAGI::WebSocket that integrates with Thunderhorse::Context. It provides a high-level API for WebSocket connections including typed send/receive methods, connection state tracking, and cleanup callbacks.
This class extends PAGI::WebSocket and mixes in Thunderhorse::Message to provide context integration.
INTERFACE
Inherits all interface from PAGI::WebSocket, and adds the interface documented below.
Attributes
context
The Thunderhorse::Context object for this request (weakened).
Required in the constructor
Methods
new
$object = $class->new(%args)
Standard Mooish constructor. Consult "Attributes" section for available constructor arguments.
update
$ws->update()
Updates the internal PAGI scope, receiver, and sender from the context's PAGI tuple. Called automatically when the context's PAGI tuple changes via setter of "pagi" in Thunderhorse::Context.