Documentation ¶
Index ¶
Constants ¶
const ( StatusOK int32 = iota StatusUnknownResource StatusSubscriptionLimitReached StatusNoResourceData StatusThrottled = 1001 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn represents a connection between the real-time activity services. It can be established from Dialer with an authorization token that relies on the party 'https://xboxlive.com/'.
A Conn controls subscriptions real-timely under a websocket connection. An index-specific JSON array is used for the communication. Conn is safe for concurrent use in multiple goroutines.
Handlers are useful to handle any events that may occur in the subscriptions controlled by Conn, and can be stored atomically to a Conn from Handle.
func (*Conn) Subscribe ¶
Subscribe attempts to subscribe with the specific resource URI, with the context to be used during the handshakes. A Subscription may be returned with fields decoded from the service.
func (*Conn) Unsubscribe ¶
func (c *Conn) Unsubscribe(ctx context.Context, sub *Subscription) error
type Dialer ¶
type Dialer struct { Options *websocket.DialOptions ErrorLog *slog.Logger }
Dialer represents the options for establishing a Conn with real-time activity services with DialContext or Dial.
func (Dialer) DialContext ¶
DialContext establishes a connection with real-time activity service. A context.Context is used to control the scene real-timely. An authorization token may be used for configuring an HTTP header to Options. An error may be returned during the dial of websocket connection.
type NopSubscriptionHandler ¶
type NopSubscriptionHandler struct{}
func (NopSubscriptionHandler) HandleEvent ¶
func (NopSubscriptionHandler) HandleEvent(json.RawMessage)
func (NopSubscriptionHandler) HandleReconnect ¶
func (NopSubscriptionHandler) HandleReconnect(*Conn)
type OutOfRangeError ¶
type OutOfRangeError struct { Payload []json.RawMessage Index int }
func (*OutOfRangeError) Error ¶
func (e *OutOfRangeError) Error() string
type Subscription ¶
type Subscription struct { ID uint32 Custom json.RawMessage // contains filtered or unexported fields }
Subscription represents a subscription contracted with the resource URI available through the real-time activity service. A Subscription may be contracted via Conn.Subscribe.
func (*Subscription) Handle ¶
func (s *Subscription) Handle(h SubscriptionHandler)
type SubscriptionHandler ¶
type SubscriptionHandler interface { HandleEvent(custom json.RawMessage) HandleReconnect(conn *Conn) }
type UnexpectedStatusError ¶
func (*UnexpectedStatusError) Error ¶
func (e *UnexpectedStatusError) Error() string