Documentation
¶
Overview ¶
Package client maintains the NG Chat WebSocket session: mint → dial → authenticate → resolve channel → subscribe, plus the heartbeat the server requires and the reconnect/dedupe logic that makes the hourly JWT-expiry disconnect invisible to the UI.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client runs one chat session with automatic reconnect.
func (*Client) Events ¶
Events returns the stream the UI should drain. It is closed when Run returns.
func (*Client) Run ¶
Run connects and keeps the session alive until ctx is canceled or the server sends a do-not-reconnect close ("client close", "server close", "idle timeout") or a hard auth rejection.
func (*Client) SendTyping ¶
func (c *Client) SendTyping()
SendTyping signals composing; errors are ignorable.
type Config ¶
type Config struct {
WSURL string
Channel string
Minter auth.Minter
// Cookie is an extra Cookie header sent on the WS upgrade (dev
// proxy routing).
Cookie string
}
Config wires a Client.
type Event ¶
type Event struct {
// Msg is a decoded protocol value (protocol.Message etc.) or nil
// for pure state changes.
Msg any
// State is the connection state as of this event.
State State
// Gap is true when a reconnect's backfill did not overlap
// already-seen messages — history was lost and cannot be fetched.
Gap bool
// Err carries the terminal error when State is StateStopped.
Err error
}
Event is what the UI consumes: a decoded protocol message, a state change, or a detected history gap after reconnecting.