rta

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusOK int32 = iota
	StatusUnknownResource
	StatusSubscriptionLimitReached
	StatusNoResourceData
	StatusThrottled          = 1001
	StatusServiceUnavailable = 1002
)

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) Close

func (c *Conn) Close() (err error)

Close closes the websocket connection with websocket.StatusNormalClosure.

func (*Conn) Subscribe

func (c *Conn) Subscribe(ctx context.Context, resourceURI string) (*Subscription, error)

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

func (d Dialer) DialContext(ctx context.Context, src xsapi.TokenSource) (*Conn, error)

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

type UnexpectedStatusError struct {
	Code    int32
	Message string
}

func (*UnexpectedStatusError) Error

func (e *UnexpectedStatusError) Error() string

Jump to

Keyboard shortcuts

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