Versions in this module Expand all Collapse all v1 v1.0.0 Sep 7, 2026 Changes in this version + const ReasonInvalidRequest + const ReasonRemote + const ReasonServerRestart + const ReasonUnauthorized + const SubprotocolUnsupported + const SubprotocolV1JSON + var ErrAlreadyConnected = errors.New("actioncable: already connected") + var ErrClosed = errors.New("actioncable: client closed") + var ErrGaveUp = errors.New("actioncable: gave up connecting") + var ErrNoProtocols = errors.New("actioncable: no protocols to offer") + var ErrNotConnected = errors.New("actioncable: not connected") + var ErrRejected = errors.New("actioncable: subscription rejected") + var ErrUnsubscribed = errors.New("actioncable: unsubscribed") + var ErrUnsupportedSubprotocol = errors.New("actioncable: unsupported subprotocol") + type Client struct + func New(url string, options ...Option) *Client + func (c *Client) Close() error + func (c *Client) Connect(ctx context.Context) error + func (c *Client) Connected() bool + func (c *Client) Done() <-chan struct{} + func (c *Client) Err() error + func (c *Client) Subscribe(ctx context.Context, identifier Identifier, options ...SubscriptionOption) (*Subscription, error) + type Command struct + Data string + Identifier string + Name CommandName + type CommandName string + const CommandMessage + const CommandSubscribe + const CommandUnsubscribe + type Conn interface + Close func() error + Read func(ctx context.Context) ([]byte, error) + Subprotocol func() string + Write func(ctx context.Context, payload []byte) error + type DialOptions struct + Header http.Header + Subprotocols []string + type DisconnectError struct + Reason string + Reconnect bool + func (e *DisconnectError) Error() string + type Identifier struct + Channel string + Params Params + func (i Identifier) String() string + type Incoming struct + Identifier string + Kind Kind + Message Message + Reason string + Reconnect bool + type Kind int + const KindConfirmation + const KindDisconnect + const KindMessage + const KindPing + const KindRejection + const KindWelcome + func (k Kind) String() string + type Logger interface + Printf func(format string, args ...any) + type LoggerFunc func(format string, args ...any) + func (f LoggerFunc) Printf(format string, args ...any) + type Message json.RawMessage + func (m Message) String() string + func (m Message) Unmarshal(value any) error + type Option func(*Client) + func WithAdditionalProtocols(protocols ...Protocol) Option + func WithBackoff(initial, longest time.Duration) Option + func WithCookie(cookie string) Option + func WithHeader(header http.Header) Option + func WithHeaderFunc(build func(ctx context.Context) (http.Header, error)) Option + func WithLogger(logger Logger) Option + func WithMaxAttempts(attempts int) Option + func WithMessageBuffer(messages int) Option + func WithOrigin(origin string) Option + func WithProtocols(protocols ...Protocol) Option + func WithStaleAfter(after time.Duration) Option + func WithSubscribeRetry(retry time.Duration) Option + func WithTransport(transport Transport) Option + type Params map[string]any + type Protocol interface + Decode func(payload []byte) (Incoming, error) + Encode func(command Command) ([]byte, error) + Subprotocol func() string + type Subscription struct + func (s *Subscription) Err() error + func (s *Subscription) Key() string + func (s *Subscription) Messages() <-chan Message + func (s *Subscription) Perform(ctx context.Context, action string, data any) error + func (s *Subscription) Send(ctx context.Context, data any) error + func (s *Subscription) Unsubscribe() error + type SubscriptionOption func(*Subscription) + func OnConnected(callback func(reconnected bool)) SubscriptionOption + func OnDisconnected(callback func(willReconnect bool)) SubscriptionOption + func OnRejected(callback func()) SubscriptionOption + type Transport interface + Dial func(ctx context.Context, url string, options DialOptions) (Conn, error) + type V1JSON struct + func (V1JSON) Decode(payload []byte) (Incoming, error) + func (V1JSON) Encode(command Command) ([]byte, error) + func (V1JSON) Subprotocol() string + type WebSocketTransport struct + Dialer *net.Dialer + HandshakeTimeout time.Duration + MaxMessageSize int64 + TLSConfig *tls.Config + WriteTimeout time.Duration + func (t *WebSocketTransport) Dial(ctx context.Context, rawURL string, options DialOptions) (Conn, error)