rta

package
v0.0.0-...-f3e7309 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: GPL-3.0 Imports: 14 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.

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

func (c *Conn) Close() 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 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) 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)

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

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