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.
SubscriptionHandlers are useful to handle any events that may occur in the subscriptions controlled by Conn, and can be stored atomically to a Subscription from Subscription.Handle.
func (*Conn) Subscribe ¶
Subscribe attempts to subscribe with the specific resource URI, with the context.Context to be used during the handshake. A Subscription may be returned, which contains an ID and Custom data as the result of handshake.
func (*Conn) Unsubscribe ¶
func (c *Conn) Unsubscribe(ctx context.Context, sub *Subscription) error
Unsubscribe attempts to unsubscribe with a Subscription associated with an ID, with the context.Context to be used during the handshake. An error may be returned.
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) Dial ¶
func (d Dialer) Dial(src xsapi.TokenSource) (*Conn, error)
Dial calls DialContext with a 15 seconds timeout.
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)
type OutOfRangeError ¶
type OutOfRangeError struct {
Payload []json.RawMessage
Index int
}
An OutOfRangeError occurs when reading values from payload received from the service. The Payload specifies the remaining values included in the payload, and the Index specifies a length of values that is missing from the payload.
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)
}
type UnexpectedStatusError ¶
func (*UnexpectedStatusError) Error ¶
func (e *UnexpectedStatusError) Error() string