sse
Generated by tinox doc
Server-Sent Events (W3C EventSource, text/event-stream) — one-way server push over plain HTTP for live dashboards/notifications, lighter weight than a full WebSocket handshake when the client never needs to talk back.
Event stream
import tinox.core.sse;
class Main
{
fnc main() -> Int32
{
let srv: Int64 = SseServer::listen(8080);
let conn: Int64 = SseServer::accept(srv);
if conn > 0
{
Sse::sendEvent(conn, "message", "hello");
Sse::sendComment(conn); // keepalive
Sse::close(conn);
}
return 0;
}
}
class Sse
Methods
fn handshake(conn: Int64) → Bool
fn sendEvent(conn: Int64, event: String, data: String) → Nothing
fn sendComment(conn: Int64) → Nothing
fn close(conn: Int64) → Nothing
class SseServer
Methods
fn listen(port: Int64) → Int64
fn accept(srv: Int64) → Int64
fn listenTls(port: Int64, certPath: String, keyPath: String) → Int64
fn acceptTls(srv: Int64) → Int64