class Radbas::ServerSentEvents::Stream

Overview

An open event stream. Safe to send to from multiple fibers.

Defined in:

radbas-framework/server_sent_events.cr

Constant Summary

HEARTBEAT = 15.seconds

Sent while open, so proxies keep the connection and closed connections are noticed.

Constructors

Instance Method Summary

Constructor Detail

def self.new(io : IO) #

[View source]

Instance Method Detail

def close : Nil #

[View source]
def closed? : Bool #

[View source]
def comment(text : String = "") : Nil #

Sends a comment, which clients ignore. Does nothing if the stream is closed.


[View source]
def on_close(&on_close : -> ) : Nil #

Called once when the stream closes, including when the client disconnects.


[View source]
def send(message : Message) : Nil #

Sends message. Raises IO::Error if the stream is closed.


[View source]
def send(data : Iterable(String), event : String | Nil = nil, id : String | Nil = nil, retry : Int64 | Nil = nil) : Nil #

[View source]
def start : Nil #

Blocks until the stream is closed.


[View source]