NAME
Thunderhorse::SSE - Server-Sent Events wrapper for Thunderhorse
SYNOPSIS
async sub handle ($self, $ctx)
{
my $sse = $ctx->sse;
await $sse->keepalive(30);
await $sse->every(2, async sub {
await $sse->send_json({time => time()});
});
}
DESCRIPTION
Thunderhorse::SSE is a thin wrapper around PAGI::SSE that integrates with Thunderhorse::Context. It provides a high-level API for Server-Sent Events connections including multiple send methods, connection state tracking, and cleanup callbacks.
This class extends PAGI::SSE and mixes in Thunderhorse::Message to provide context integration.
INTERFACE
Inherits all interface from PAGI::SSE, 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
$sse->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.