protocol

package
v1.0.0-rc.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package protocol holds the NG Chat wire types. The structs in protocol_gen.go are generated from the JSON Schema spec ngchat derives from its Zod schemas (src/shared/protocol/protocol.schema.json, ADR 0010); regenerate with NGCHAT_UPSTREAM=<checkout> go generate.

The server strict-validates client frames, rejecting unknown fields, so what this package sends must match the spec exactly. Server frames are decoded tolerantly instead (Decode, ADR 0002), so server-side additions never break this client.

Index

Constants

View Source
const (
	MaxAwayMessageRawLength     = 256
	MaxAwayMessageRenderedBytes = 32768
	MaxFrameBytes               = 67108864
	MaxRosterRowsInBudget       = 10000
	SubscribedBackfillRows      = 25
	SubscribedNotificationRows  = 25
)

Size limits from the spec's x-limits: the server's contract for how large frames and their lists may grow.

View Source
const (
	ClientAuthenticateFrameName          = "authenticate"
	ClientMessageFrameName               = "message"
	ClientDirectTypingFrameName          = "directTyping"
	ClientGetChannelIDFrameName          = "getChannelID"
	ClientPingFrameName                  = "ping"
	ClientReauthenticateFrameName        = "reauthenticate"
	ClientSubscribeFrameName             = "subscribe"
	ClientTypingFrameName                = "typing"
	ClientUnsubscribeFrameName           = "unsubscribe"
	ServerAirhornFrameName               = "airhorn"
	ServerAuthenticatedFrameName         = "authenticated"
	ServerAwayFrameName                  = "away"
	ServerChannelIDFrameName             = "channelID"
	ServerErrorFrameName                 = "error"
	ServerIdleTimeoutFrameName           = "idleTimeout"
	ServerKickedFrameName                = "kicked"
	ServerMessageFrameName               = "message"
	ServerDirectMessageFrameName         = "directMessage"
	ServerDirectTypingFrameName          = "directTyping"
	ServerMeMessageFrameName             = "meMessage"
	ServerMessageEmbedsFrameName         = "messageEmbeds"
	ServerPlaySoundEffectFrameName       = "playSoundEffect"
	ServerPlaySoundboardTriggerFrameName = "playSoundboardTrigger"
	ServerPongFrameName                  = "pong"
	ServerRevalidateFrameName            = "revalidate"
	ServerRevalidatedFrameName           = "revalidated"
	ServerServerMessageFrameName         = "serverMessage"
	ServerSlapMessageFrameName           = "slapMessage"
	ServerSubscribedFrameName            = "subscribed"
	ServerTypingFrameName                = "typing"
	ServerUnauthorizedFrameName          = "unauthorized"
	ServerUserJoinedFrameName            = "userJoined"
	ServerUserLeftFrameName              = "userLeft"
	ServerUserUpdatedFrameName           = "userUpdated"
	ServerUnsubscribedFrameName          = "unsubscribed"
)

Frame names: the name discriminator each frame carries on the wire.

Variables

This section is empty.

Functions

func Decode

func Decode(data []byte) any

Decode maps a server frame to its typed value: Message for the five chat-line frames, the generated struct for every other frame the spec lists. It never fails: unrecognized names and undecodable payloads come back as Unknown.

func FrameName

func FrameName(data []byte) string

FrameName returns the name discriminator of any frame, client or server, or "" when the bytes are not a named frame. Loggers use it to label frames without decoding them.

Types

type ClientAuthenticateFrame

type ClientAuthenticateFrame struct {
	Name  string `json:"name"`
	Token string `json:"token"`
}

ClientAuthenticateFrame is the client→server "authenticate" frame.

First frame on a new socket, carrying a chat JWT. Accepted once per socket; swap the token on an authenticated socket with `reauthenticate` instead.

func NewAuthenticate

func NewAuthenticate(token string) ClientAuthenticateFrame

NewAuthenticate builds the first frame on a new socket. Only authenticate and ping are accepted pre-auth; the server closes unauthenticated sockets after 15s.

type ClientDirectTypingFrame

type ClientDirectTypingFrame struct {
	Name       string `json:"name"`
	ChannelID  int64  `json:"channelID"`
	ToUsername string `json:"toUsername"`
}

ClientDirectTypingFrame is the client→server "directTyping" frame.

Tells one user, rather than the whole channel, that the sender is writing them a direct message. Kept apart from `typing` so a client that only knows the channel frame never mistakes it for channel typing. The server drops it silently when the recipient is offline, blocked, or ignoring the sender, so it never reveals anything a DM attempt would not.

type ClientGetChannelIDFrame

type ClientGetChannelIDFrame struct {
	Name        string `json:"name"`
	ChannelName string `json:"channelName"`
}

ClientGetChannelIDFrame is the client→server "getChannelID" frame.

func NewGetChannelID

func NewGetChannelID(channelName string) ClientGetChannelIDFrame

NewGetChannelID builds a channel-name lookup. Names are lowercase on the server; callers should lowercase before sending. Unknown names come back as an error frame with a redirectChannel.

type ClientMessageFrame

type ClientMessageFrame struct {
	Name       string `json:"name"`
	ChannelID  int64  `json:"channelID"`
	IsMarkdown *bool  `json:"isMarkdown,omitempty"`
	Message    string `json:"message"`
}

ClientMessageFrame is the client→server "message" frame.

func NewChatMessage

func NewChatMessage(channelID int64, text string) ClientMessageFrame

NewChatMessage builds a chat line (1..5000 chars) for a subscribed channel. Slash commands (/me, /dm, ...) are plain message text parsed server-side.

type ClientPingFrame

type ClientPingFrame struct {
	Name string              `json:"name"`
	Data ClientPingFrameData `json:"data"`
}

ClientPingFrame is the client→server "ping" frame.

Keepalive. The server answers with `pong` echoing `data`.

func NewPing

func NewPing(unixMilli int64) ClientPingFrame

NewPing builds a heartbeat stamped with epoch milliseconds. The server terminates any socket with no inbound traffic for 15 seconds, so clients must ping continuously (the browser client uses a 1-5s cadence).

type ClientPingFrameData

type ClientPingFrameData struct {
	Time int64 `json:"time"`
}

ClientPingFrameData is the ClientPingFrame.data object.

type ClientReauthenticateFrame

type ClientReauthenticateFrame struct {
	Name  string `json:"name"`
	Token string `json:"token"`
}

ClientReauthenticateFrame is the client→server "reauthenticate" frame.

Answers a server `revalidate` with a freshly minted token. Deliberately distinct from `authenticate`: the server replaces the socket's claim snapshot in place rather than re-running the join/subscribe/motd pipeline, and the already-authenticated guard on `authenticate` stays.

func NewReauthenticate

func NewReauthenticate(token string) ClientReauthenticateFrame

NewReauthenticate answers a server revalidate with a freshly minted chat JWT. The server refuses a token for a different account or one whose expiry is not strictly later than the token in force, and caps attempts per token (~5), so send at most one per revalidate.

type ClientSubscribeFrame

type ClientSubscribeFrame struct {
	Name      string `json:"name"`
	ChannelID int64  `json:"channelID"`
}

ClientSubscribeFrame is the client→server "subscribe" frame.

func NewSubscribe

func NewSubscribe(channelID int64) ClientSubscribeFrame

NewSubscribe joins a channel by ID; the reply is a subscribed frame with the backfill buffer and the roster.

type ClientTypingFrame

type ClientTypingFrame struct {
	Name      string `json:"name"`
	ChannelID int64  `json:"channelID"`
}

ClientTypingFrame is the client→server "typing" frame.

The sender is typing in `channelID`. Rebroadcast to the channel as a server `typing` frame.

func NewTyping

func NewTyping(channelID int64) ClientTypingFrame

NewTyping signals the user is composing; exempt from flood limits.

type ClientUnsubscribeFrame

type ClientUnsubscribeFrame struct {
	Name      string `json:"name"`
	ChannelID int64  `json:"channelID"`
}

ClientUnsubscribeFrame is the client→server "unsubscribe" frame.

func NewUnsubscribe

func NewUnsubscribe(channelID int64) ClientUnsubscribeFrame

NewUnsubscribe leaves a channel.

type Message

type Message struct {
	Name        string
	ChannelID   int64
	ID          *int64
	Message     string
	MessageRaw  string
	Mentions    []string
	IsSpoiler   bool
	IsAdmin     bool
	IsChatMod   bool
	UserIcon    string
	UserID      int64
	Username    string
	UserPageURL string
	ServerTime  int64
}

Message is a chat line: one view of the message, meMessage, slapMessage, serverMessage and directMessage frames, which gap detection and the transcript treat as one thing. Check Name to tell them apart. Message is server-rendered HTML; MessageRaw is the sender's original text. Decode builds it from the generated frame structs, so a field a frame does not carry is left zero: only message has IsSpoiler, meMessage and serverMessage carry no user decoration, and directMessage has no ID. ID is set on every backfill row but, live, only on message: the server sends the other kinds before it stores them.

type ServerAirhornFrame

type ServerAirhornFrame struct {
	Name       string `json:"name"`
	ChannelID  int64  `json:"channelID"`
	ServerTime int64  `json:"serverTime"`
}

ServerAirhornFrame is the server→client "airhorn" frame.

type ServerAuthenticatedFrame

type ServerAuthenticatedFrame struct {
	Name       string `json:"name"`
	IsAdmin    bool   `json:"isAdmin"`
	IsChatMod  bool   `json:"isChatMod"`
	IsSiteMod  bool   `json:"isSiteMod"`
	MOTD       string `json:"motd"`
	ServerTime int64  `json:"serverTime"`
	UserID     int64  `json:"userID"`
	Username   string `json:"username"`
}

ServerAuthenticatedFrame is the server→client "authenticated" frame.

type ServerAwayFrame

type ServerAwayFrame struct {
	Name           string `json:"name"`
	AwayMessage    string `json:"awayMessage,omitempty"`
	AwayMessageRaw string `json:"awayMessageRaw,omitempty"`
	ChannelID      int64  `json:"channelID"`
	// The stored row id. Set on `messageBuffer` backfill rows. Live frames
	// carry it only for `message`; the other kinds are sent before the row is
	// written. Clients use it to dedupe backfill against lines they already
	// hold.
	ID          *int64   `json:"id,omitempty"`
	IsAdmin     bool     `json:"isAdmin"`
	IsAway      *bool    `json:"isAway,omitempty"`
	IsChatMod   bool     `json:"isChatMod"`
	Mentions    []string `json:"mentions,omitempty"`
	Message     string   `json:"message,omitempty"`
	MessageRaw  string   `json:"messageRaw,omitempty"`
	ServerTime  int64    `json:"serverTime"`
	UserID      int64    `json:"userID"`
	UserIcon    string   `json:"userIcon"`
	UserPageURL string   `json:"userPageURL"`
	Username    string   `json:"username"`
}

ServerAwayFrame is the server→client "away" frame.

type ServerChannelIDFrame

type ServerChannelIDFrame struct {
	Name        string `json:"name"`
	ChannelID   int64  `json:"channelID"`
	ChannelName string `json:"channelName"`
	ServerTime  int64  `json:"serverTime"`
}

ServerChannelIDFrame is the server→client "channelID" frame.

type ServerDirectMessageFrame

type ServerDirectMessageFrame struct {
	Name        string `json:"name"`
	ChannelID   int64  `json:"channelID"`
	IsAdmin     bool   `json:"isAdmin"`
	IsChatMod   bool   `json:"isChatMod"`
	Message     string `json:"message"`
	MessageRaw  string `json:"messageRaw"`
	ServerTime  int64  `json:"serverTime"`
	ToUsername  string `json:"toUsername"`
	UserID      int64  `json:"userID"`
	UserIcon    string `json:"userIcon"`
	UserPageURL string `json:"userPageURL"`
	Username    string `json:"username"`
}

ServerDirectMessageFrame is the server→client "directMessage" frame.

type ServerDirectTypingFrame

type ServerDirectTypingFrame struct {
	Name       string `json:"name"`
	ChannelID  int64  `json:"channelID"`
	ServerTime int64  `json:"serverTime"`
	ToUsername string `json:"toUsername"`
	UserID     int64  `json:"userID"`
	Username   string `json:"username"`
}

ServerDirectTypingFrame is the server→client "directTyping" frame.

Sent only to the recipient's instances in the channel: `username` is writing them a direct message. `toUsername` echoes the name the sender addressed, so a client holding several sessions can tell it is the target.

type ServerErrorFrame

type ServerErrorFrame struct {
	Name            string `json:"name"`
	Message         string `json:"message,omitempty"`
	RedirectChannel string `json:"redirectChannel,omitempty"`
	ServerTime      int64  `json:"serverTime"`
}

ServerErrorFrame is the server→client "error" frame.

type ServerIdleTimeoutFrame

type ServerIdleTimeoutFrame struct {
	Name       string `json:"name"`
	Reason     string `json:"reason"`
	ServerTime int64  `json:"serverTime"`
}

ServerIdleTimeoutFrame is the server→client "idleTimeout" frame.

The user sent no chat messages for too long. The server closes the socket about 100 ms later. Admins and chat mods are exempt.

type ServerKickedFrame

type ServerKickedFrame struct {
	Name           string `json:"name"`
	ChannelID      *int64 `json:"channelID,omitempty"`
	KickedByUserID *int64 `json:"kickedByUserID,omitempty"`
	Reason         string `json:"reason,omitempty"`
	ServerTime     int64  `json:"serverTime"`
}

ServerKickedFrame is the server→client "kicked" frame.

Sent to each of the user's sockets in `channelID`, or on the whole server when `channelID` is absent, just before the server closes them.

type ServerMeMessageFrame

type ServerMeMessageFrame struct {
	Name      string `json:"name"`
	ChannelID int64  `json:"channelID"`
	// The stored row id. Set on `messageBuffer` backfill rows. Live frames
	// carry it only for `message`; the other kinds are sent before the row is
	// written. Clients use it to dedupe backfill against lines they already
	// hold.
	ID         *int64   `json:"id,omitempty"`
	Mentions   []string `json:"mentions"`
	Message    string   `json:"message"`
	MessageRaw string   `json:"messageRaw"`
	ServerTime int64    `json:"serverTime"`
	// Set only on the `/sfx` "X played ..." line: the soundboard trigger this
	// row narrates. A client that dropped the matching `playSoundboardTrigger`
	// hides the row too, so the transcript never claims a sound nobody heard.
	TriggerID string `json:"triggerId,omitempty"`
	UserID    int64  `json:"userID"`
	Username  string `json:"username"`
}

ServerMeMessageFrame is the server→client "meMessage" frame.

type ServerMessageEmbedsFrame

type ServerMessageEmbedsFrame struct {
	Name       string                               `json:"name"`
	ChannelID  int64                                `json:"channelID"`
	Embeds     []ServerMessageEmbedsFrameEmbedsItem `json:"embeds"`
	ID         int64                                `json:"id"`
	ServerTime int64                                `json:"serverTime"`
	UserID     int64                                `json:"userID"`
}

ServerMessageEmbedsFrame is the server→client "messageEmbeds" frame.

Link embeds for the earlier chat `message` with this `id`, resolved after it was sent. Not sent when no embed resolves.

type ServerMessageEmbedsFrameEmbedsItem

type ServerMessageEmbedsFrameEmbedsItem struct {
	Html string `json:"html"`
	ID   string `json:"id"`
}

ServerMessageEmbedsFrameEmbedsItem is one element of ServerMessageEmbedsFrame.embeds.

type ServerMessageFrame

type ServerMessageFrame struct {
	Name      string                         `json:"name"`
	ChannelID int64                          `json:"channelID"`
	Embeds    []ServerMessageFrameEmbedsItem `json:"embeds,omitempty"`
	// The stored row id. Set on `messageBuffer` backfill rows. Live frames
	// carry it only for `message`; the other kinds are sent before the row is
	// written. Clients use it to dedupe backfill against lines they already
	// hold.
	ID                    *int64   `json:"id,omitempty"`
	IsAdmin               bool     `json:"isAdmin"`
	IsChatMod             bool     `json:"isChatMod"`
	IsSpoiler             bool     `json:"isSpoiler"`
	Mentions              []string `json:"mentions"`
	Message               string   `json:"message"`
	MessageRaw            string   `json:"messageRaw"`
	ServerTime            int64    `json:"serverTime"`
	SoundEffectsTriggered []string `json:"soundEffectsTriggered,omitempty"`
	UserID                int64    `json:"userID"`
	UserIcon              string   `json:"userIcon"`
	UserPageURL           string   `json:"userPageURL"`
	Username              string   `json:"username"`
}

ServerMessageFrame is the server→client "message" frame.

type ServerMessageFrameEmbedsItem

type ServerMessageFrameEmbedsItem struct {
	Html string `json:"html"`
	ID   string `json:"id"`
}

ServerMessageFrameEmbedsItem is one element of ServerMessageFrame.embeds.

type ServerPlaySoundEffectFrame

type ServerPlaySoundEffectFrame struct {
	Name       string   `json:"name"`
	ChannelID  int64    `json:"channelID"`
	EffectName string   `json:"effectName"`
	Loop       *bool    `json:"loop,omitempty"`
	ServerTime int64    `json:"serverTime"`
	Sprite     string   `json:"sprite,omitempty"`
	Volume     *float64 `json:"volume,omitempty"`
}

ServerPlaySoundEffectFrame is the server→client "playSoundEffect" frame.

type ServerPlaySoundboardTriggerFrame

type ServerPlaySoundboardTriggerFrame struct {
	Name       string `json:"name"`
	ChannelID  int64  `json:"channelID"`
	ServerTime int64  `json:"serverTime"`
	TriggerID  string `json:"triggerId"`
	// Who asked for the sound. Optional so frames from an older server still
	// validate. Lets a client show a "sound skipped" notice only to the user
	// who triggered a sound it dropped.
	UserID *int64 `json:"userID,omitempty"`
}

ServerPlaySoundboardTriggerFrame is the server→client "playSoundboardTrigger" frame.

type ServerPongFrame

type ServerPongFrame struct {
	Name       string              `json:"name"`
	Data       ServerPongFrameData `json:"data"`
	ServerTime int64               `json:"serverTime"`
}

ServerPongFrame is the server→client "pong" frame.

type ServerPongFrameData

type ServerPongFrameData struct {
	Time int64 `json:"time"`
}

ServerPongFrameData is the ServerPongFrame.data object.

type ServerRevalidateFrame

type ServerRevalidateFrame struct {
	Name       string `json:"name"`
	ServerTime int64  `json:"serverTime"`
}

ServerRevalidateFrame is the server→client "revalidate" frame.

Nudge sent shortly before the authenticated token's close deadline. The client answers with `reauthenticate` carrying a freshly minted token so the socket's claim snapshot is replaced in place instead of the socket being closed and reconnected. Clients that ignore it fall back to the close/reconnect path.

type ServerRevalidatedFrame

type ServerRevalidatedFrame struct {
	Name       string `json:"name"`
	IsAdmin    bool   `json:"isAdmin"`
	IsChatMod  bool   `json:"isChatMod"`
	IsSiteMod  bool   `json:"isSiteMod"`
	ServerTime int64  `json:"serverTime"`
}

ServerRevalidatedFrame is the server→client "revalidated" frame.

Acknowledges a successful `reauthenticate`. Carries the privilege flags from the new token so a role change (a demoted mod, say) reaches the UI without a reload.

type ServerServerMessageFrame

type ServerServerMessageFrame struct {
	Name      string `json:"name"`
	ChannelID *int64 `json:"channelID,omitempty"`
	// The stored row id. Set on `messageBuffer` backfill rows. Live frames
	// carry it only for `message`; the other kinds are sent before the row is
	// written. Clients use it to dedupe backfill against lines they already
	// hold.
	ID         *int64 `json:"id,omitempty"`
	Message    string `json:"message"`
	MessageRaw string `json:"messageRaw"`
	ServerTime int64  `json:"serverTime"`
}

ServerServerMessageFrame is the server→client "serverMessage" frame.

type ServerSlapMessageFrame

type ServerSlapMessageFrame struct {
	Name      string `json:"name"`
	ChannelID int64  `json:"channelID"`
	// The stored row id. Set on `messageBuffer` backfill rows. Live frames
	// carry it only for `message`; the other kinds are sent before the row is
	// written. Clients use it to dedupe backfill against lines they already
	// hold.
	ID          *int64   `json:"id,omitempty"`
	IsAdmin     bool     `json:"isAdmin"`
	IsChatMod   bool     `json:"isChatMod"`
	Mentions    []string `json:"mentions"`
	Message     string   `json:"message"`
	MessageRaw  string   `json:"messageRaw"`
	ServerTime  int64    `json:"serverTime"`
	UserID      int64    `json:"userID"`
	UserIcon    string   `json:"userIcon"`
	UserPageURL string   `json:"userPageURL"`
	Username    string   `json:"username"`
}

ServerSlapMessageFrame is the server→client "slapMessage" frame.

type ServerSubscribedFrame

type ServerSubscribedFrame struct {
	Name           string `json:"name"`
	AwayMessage    string `json:"awayMessage"`
	AwayMessageRaw string `json:"awayMessageRaw"`
	// Deprecated compat shim with a fixed value. Ignore it.
	CelebrationType string `json:"celebrationType,omitempty"`
	ChannelID       int64  `json:"channelID"`
	ChannelName     string `json:"channelName"`
	// Deprecated compat shim with a fixed value. Ignore it.
	ComicChat *bool `json:"comicChat,omitempty"`
	IsAway    bool  `json:"isAway"`
	// Each element is one raw frame (away, message, meMessage, serverMessage,
	// slapMessage); decode it with Decode.
	MessageBuffer []json.RawMessage                        `json:"messageBuffer"`
	Notifications []ServerSubscribedFrameNotificationsItem `json:"notifications"`
	ServerTime    int64                                    `json:"serverTime"`
	UserList      []ServerSubscribedFrameUserListItem      `json:"userList"`
}

ServerSubscribedFrame is the server→client "subscribed" frame.

The channel state, sent when the socket joins a channel: recent `messageBuffer` backfill, notifications, and the `userList` roster. The largest frame the server sends; see `x-limits`.

type ServerSubscribedFrameNotificationsItem

type ServerSubscribedFrameNotificationsItem struct {
	Message     string `json:"message"`
	MessageRaw  string `json:"messageRaw"`
	MessageType string `json:"messageType"`
	ServerTime  int64  `json:"serverTime"`
	UserID      int64  `json:"userID"`
	Username    string `json:"username"`
}

ServerSubscribedFrameNotificationsItem is one element of ServerSubscribedFrame.notifications.

type ServerSubscribedFrameUserListItem

type ServerSubscribedFrameUserListItem struct {
	AwayMessage    string `json:"awayMessage"`
	AwayMessageRaw string `json:"awayMessageRaw"`
	IsAdmin        bool   `json:"isAdmin"`
	IsAway         bool   `json:"isAway"`
	IsChatMod      bool   `json:"isChatMod"`
	UserID         int64  `json:"userID"`
	UserIcon       string `json:"userIcon"`
	UserPageURL    string `json:"userPageURL"`
	Username       string `json:"username"`
}

ServerSubscribedFrameUserListItem is one element of ServerSubscribedFrame.userList.

A roster row. `awayMessage` is a plain, HTML-escaped preview of the away text, not the rendered markup the `away` frame carries, so a roster stays bounded whatever the formatter does.

type ServerTypingFrame

type ServerTypingFrame struct {
	Name       string `json:"name"`
	ChannelID  int64  `json:"channelID"`
	ServerTime int64  `json:"serverTime"`
	UserID     int64  `json:"userID"`
	Username   string `json:"username"`
}

ServerTypingFrame is the server→client "typing" frame.

Rebroadcast of a client `typing` frame to the channel.

type ServerUnauthorizedFrame

type ServerUnauthorizedFrame struct {
	Name       string `json:"name"`
	ChannelID  *int64 `json:"channelID,omitempty"`
	Message    string `json:"message"`
	ServerTime int64  `json:"serverTime"`
}

ServerUnauthorizedFrame is the server→client "unauthorized" frame.

type ServerUnsubscribedFrame

type ServerUnsubscribedFrame struct {
	Name       string `json:"name"`
	ChannelID  int64  `json:"channelID"`
	ServerTime int64  `json:"serverTime"`
	UserID     int64  `json:"userID"`
	Username   string `json:"username"`
}

ServerUnsubscribedFrame is the server→client "unsubscribed" frame.

type ServerUserJoinedFrame

type ServerUserJoinedFrame struct {
	Name           string `json:"name"`
	AwayMessage    string `json:"awayMessage"`
	AwayMessageRaw string `json:"awayMessageRaw"`
	ChannelID      int64  `json:"channelID"`
	IsAdmin        bool   `json:"isAdmin"`
	IsAway         bool   `json:"isAway"`
	IsChatMod      bool   `json:"isChatMod"`
	ServerTime     int64  `json:"serverTime"`
	UserID         int64  `json:"userID"`
	UserIcon       string `json:"userIcon"`
	UserPageURL    string `json:"userPageURL"`
	Username       string `json:"username"`
}

ServerUserJoinedFrame is the server→client "userJoined" frame.

type ServerUserLeftFrame

type ServerUserLeftFrame struct {
	Name        string `json:"name"`
	ChannelID   int64  `json:"channelID"`
	IsAdmin     bool   `json:"isAdmin"`
	IsChatMod   bool   `json:"isChatMod"`
	ServerTime  int64  `json:"serverTime"`
	UserID      int64  `json:"userID"`
	UserIcon    string `json:"userIcon"`
	UserPageURL string `json:"userPageURL"`
	Username    string `json:"username"`
}

ServerUserLeftFrame is the server→client "userLeft" frame.

type ServerUserUpdatedFrame

type ServerUserUpdatedFrame struct {
	Name           string `json:"name"`
	AwayMessage    string `json:"awayMessage"`
	AwayMessageRaw string `json:"awayMessageRaw"`
	ChannelID      int64  `json:"channelID"`
	IsAdmin        bool   `json:"isAdmin"`
	IsAway         bool   `json:"isAway"`
	IsChatMod      bool   `json:"isChatMod"`
	ServerTime     int64  `json:"serverTime"`
	UserID         int64  `json:"userID"`
	UserIcon       string `json:"userIcon"`
	UserPageURL    string `json:"userPageURL"`
	Username       string `json:"username"`
}

ServerUserUpdatedFrame is the server→client "userUpdated" frame.

A roster entry that changed while the user stayed in the channel, today a role change picked up by an in-place token renewal. Same shape as `userJoined` so clients can reuse their upsert, but a distinct name: a refresh must not play the join sound or print a join notice, and clients that predate it drop it rather than announcing a join that never happened.

type Unknown

type Unknown struct {
	Name string
}

Unknown is any frame this client does not (yet) understand, including known names whose payload failed to decode. Callers must treat it as ignorable — that tolerance is what lets old binaries survive protocol additions (ADR 0002).

Directories

Path Synopsis
Command gen writes internal/protocol/protocol_gen.go from the JSON Schema spec in the upstream ngchat checkout, invoked by the //go:generate directive in internal/protocol/doc.go (ADR 0010).
Command gen writes internal/protocol/protocol_gen.go from the JSON Schema spec in the upstream ngchat checkout, invoked by the //go:generate directive in internal/protocol/doc.go (ADR 0010).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL