Versions in this module Expand all Collapse all v0 v0.1.1 Jul 7, 2026 v0.1.0 Jul 7, 2026 Changes in this version + const CodeAuthExpired + const CodeBadAuth + const CodeBadFrame + const CodeBootstrap + const CodeCapability + const CodeChannelDenied + const CodeForbidden + const CodeNotFound + const CodeRateLimited + const CodeServer + const DefaultEndpoint + func CreateJWT(key string, params CreateJWTParams) (string, error) + func GenerateRandomKey(bits int) (string, error) + func IsCipherEncoding(encoding string) bool + type Auth struct + func (a *Auth) CreateJWT(params CreateJWTParams) (string, error) + type BatchChannelResult struct + Channel string + Err error + type BatchMessage struct + Data any + Name string + type BatchOptions struct + Interval time.Duration + MaxMessages int + type BatchPublishResult struct + FailureCount int + Results []BatchChannelResult + SuccessCount int + type BatchSpec struct + Channels []string + Messages []BatchMessage + type Capability map[string][]string + type Channel struct + Name string + Presence *Presence + func (ch *Channel) Attach(ctx context.Context) error + func (ch *Channel) Detach(ctx context.Context) error + func (ch *Channel) Flush() + func (ch *Channel) History(ctx context.Context, params HistoryParams) (*HistoryResult, error) + func (ch *Channel) Off() + func (ch *Channel) On(listener func(ChannelStateChange)) func() + func (ch *Channel) OnEvent(event ChannelEvent, listener func(ChannelStateChange)) func() + func (ch *Channel) Once(event ChannelEvent, listener func(ChannelStateChange)) func() + func (ch *Channel) Publish(ctx context.Context, name string, data any, options ...PublishOption) error + func (ch *Channel) PublishBatch(ctx context.Context, messages []BatchMessage, options ...PublishOption) error + func (ch *Channel) State() ChannelState + func (ch *Channel) Subscribe(listener func(*Message), names ...string) func() + func (ch *Channel) Unsubscribe() + type ChannelEvent string + const ChannelEventUpdate + type ChannelOption func(*channelSettings) + func WithBatchOptions(batch BatchOptions) ChannelOption + func WithCipher(cipher *Cipher) ChannelOption + type ChannelState string + const ChannelAttached + const ChannelAttaching + const ChannelDetached + const ChannelDetaching + const ChannelFailed + const ChannelInitialized + const ChannelSuspended + type ChannelStateChange struct + Current ChannelState + Previous ChannelState + Reason error + Resumed bool + type Channels struct + func (chans *Channels) Get(name string, options ...ChannelOption) *Channel + func (chans *Channels) Release(name string) + type Cipher struct + func NewCipher(params CipherParams) (*Cipher, error) + func (c *Cipher) Decrypt(encoding string, data json.RawMessage) (json.RawMessage, error) + func (c *Cipher) Encrypt(value any) (*EncryptResult, error) + type CipherAlgorithm string + const AES128GCM + const AES256GCM + type CipherParams struct + Algorithm CipherAlgorithm + Key []byte + KeyBase64 string + type Client struct + Auth *Auth + Channels *Channels + Connection *Connection + func New(options Options) (*Client, error) + func (c *Client) BatchPublish(ctx context.Context, specs ...BatchSpec) (*BatchPublishResult, error) + func (c *Client) Close() + func (c *Client) Connect(ctx context.Context) error + type Connection struct + func (c *Connection) ClientID() string + func (c *Connection) Close() + func (c *Connection) Connect(ctx context.Context) error + func (c *Connection) ID() string + func (c *Connection) Off() + func (c *Connection) On(listener func(ConnectionStateChange)) func() + func (c *Connection) OnState(state ConnectionState, listener func(ConnectionStateChange)) func() + func (c *Connection) Once(state ConnectionState, listener func(ConnectionStateChange)) func() + func (c *Connection) State() ConnectionState + type ConnectionState string + const ConnectionClosed + const ConnectionClosing + const ConnectionConnected + const ConnectionConnecting + const ConnectionDisconnected + const ConnectionFailed + const ConnectionInitialized + type ConnectionStateChange struct + Current ConnectionState + Reason error + type CreateJWTParams struct + Capability Capability + CapabilityJSON string + ClientID string + TTL time.Duration + type EncryptResult struct + Data string + Encoding string + type HistoryParams struct + Before uint64 + Limit int + type HistoryResult struct + Messages []*Message + More bool + type Message struct + Channel string + ClientID string + Data json.RawMessage + Encoding string + Ephemeral bool + ID string + Name string + Serial uint64 + Timestamp int64 + type Options struct + AuthCallback func(ctx context.Context) (string, error) + Batch *BatchOptions + ClientID string + DisableAutoReconnect bool + DisableQueueing bool + Endpoint string + InitialReconnectDelay time.Duration + Key string + MaxReconnectDelay time.Duration + Token string + type PaginatedResult struct + Items []T + func (p *PaginatedResult[T]) HasNext() bool + func (p *PaginatedResult[T]) IsLast() bool + func (p *PaginatedResult[T]) Next(ctx context.Context) (*PaginatedResult[T], error) + type Presence struct + func (p *Presence) Enter(ctx context.Context, data any) error + func (p *Presence) Leave(ctx context.Context) error + func (p *Presence) Off() + func (p *Presence) On(action PresenceAction, listener func(*PresenceEvent)) func() + func (p *Presence) Once(action PresenceAction, listener func(*PresenceEvent)) func() + func (p *Presence) Subscribe(listener func(*PresenceEvent)) func() + func (p *Presence) Update(ctx context.Context, data any) error + type PresenceAction string + const PresenceEnter + const PresenceLeave + const PresenceUpdate + type PresenceEvent struct + Action PresenceAction + Channel string + ClientID string + ConnectionID string + Data json.RawMessage + Encoding string + Timestamp int64 + type PresenceMember struct + Action string + ClientID string + ConnectionID string + Data json.RawMessage + Encoding string + Timestamp int64 + type PublishOption func(*publishSettings) + func WithEphemeral() PublishOption + type PublishResult struct + MessageID string + Serial uint64 + type Rest struct + Auth *RestAuth + Channels *RestChannels + func NewRest(options RestOptions) (*Rest, error) + func (r *Rest) Time(ctx context.Context) (int64, error) + type RestAuth struct + func (a *RestAuth) RequestToken(ctx context.Context, params TokenParams) (*TokenDetails, error) + type RestChannel struct + Name string + Presence *RestPresence + func (ch *RestChannel) History(ctx context.Context, params RestHistoryParams) (*PaginatedResult[RestMessage], error) + func (ch *RestChannel) Publish(ctx context.Context, name string, data any) (*PublishResult, error) + func (ch *RestChannel) PublishMessages(ctx context.Context, messages ...RestPublishMessage) (*PublishResult, error) + type RestChannels struct + func (chans *RestChannels) Get(name string, options ...ChannelOption) *RestChannel + func (chans *RestChannels) Release(name string) + type RestError struct + Code int + Message string + StatusCode int + func (e *RestError) Error() string + type RestHistoryParams struct + Before uint64 + Direction string + Limit int + type RestMessage struct + ClientID string + Data json.RawMessage + Encoding string + ID string + Name string + Serial uint64 + Timestamp int64 + type RestOptions struct + AuthCallback func(ctx context.Context) (string, error) + ClientID string + Endpoint string + HTTPClient *http.Client + Key string + Token string + type RestPresence struct + func (p *RestPresence) Get(ctx context.Context, params RestPresenceParams) (*PaginatedResult[PresenceMember], error) + type RestPresenceParams struct + ClientID string + ConnectionID string + Limit int + type RestPublishMessage struct + ClientID string + Data any + Ephemeral bool + ID string + Name string + type ServerError struct + Code int + Message string + func (e *ServerError) Error() string + type TokenDetails struct + Capability string + ClientID string + Expires int64 + Issued int64 + KeyName string + Token string + type TokenParams struct + Capability Capability + ClientID string + TTL time.Duration