ExNtfy.Stream.WS (ex_ntfy v0.1.0)

Copy Markdown View Source

WebSocket transport for ExNtfy.Subscription (format: :ws), subscribing via GET /<topics>/ws — requires the optional :mint_web_socket dependency:

{:mint_web_socket, "~> 1.0"}

Implements the subscription's internal transport contract (Mint connect → WebSocket upgrade; each text frame is one complete JSON message object, so there is no line reassembly). Server pings are answered with pongs internally; close frames and transport errors go through the subscription's normal reconnect flow. Binary frames are ignored (ntfy sends text).

Auth works both ways on the upgrade request: the Authorization header, or auth_via: :query for the ?auth= parameter — the canonical use case for the query encoding.

Summary

Types

Parser state (frames need no buffering).

Functions

Parses one text frame via ExNtfy.Message.from_json/1.

Returns a fresh parser state.

Types

parser()

@opaque parser()

Parser state (frames need no buffering).

Functions

feed(state, frame)

@spec feed(parser(), binary()) :: {[ExNtfy.Message.t()], parser()}

Parses one text frame via ExNtfy.Message.from_json/1.

new()

@spec new() :: parser()

Returns a fresh parser state.