realms

package
v1.56.2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPlayerNotInRealm = errors.New("player not in realm")
	ErrRealmNotFound    = errors.New("realm not found")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an instance of the realms api with a token.

func NewClient

func NewClient(src oauth2.TokenSource, httpClient *http.Client) *Client

NewClient returns a new Client instance with the supplied token source for authentication. If httpClient is nil, http.DefaultClient will be used to request the realms api.

func (*Client) Realm added in v1.27.0

func (c *Client) Realm(ctx context.Context, code string) (Realm, error)

Realm gets a realm by its invite code.

func (*Client) RealmAddress added in v1.55.2

func (r *Client) RealmAddress(ctx context.Context, realmID int) (RealmAddress, error)

RealmAddress requests the address and protocol used to connect to a realm from the api, and waits for the realm to start if it is currently offline.

func (*Client) Realms

func (c *Client) Realms(ctx context.Context) ([]Realm, error)

Realms gets a list of all realms the token has access to.

type NetworkProtocol added in v1.55.2

type NetworkProtocol string

NetworkProtocol is the protocol type returned by the Realms API used to connect to a realm.

const (
	NetworkProtocolDefault          NetworkProtocol = "DEFAULT"
	NetworkProtocolNetherNet        NetworkProtocol = "NETHERNET"
	NetworkProtocolNetherNetJSONRPC NetworkProtocol = "NETHERNET_JSONRPC"
)

func ParseNetworkProtocol added in v1.55.2

func ParseNetworkProtocol(protocol string) NetworkProtocol

ParseNetworkProtocol converts a network protocol string to a NetworkProtocol value.

func (NetworkProtocol) Valid added in v1.55.2

func (p NetworkProtocol) Valid() bool

Valid reports whether the protocol is one of the known constants.

type Player

type Player struct {
	UUID       string `json:"uuid"`
	Name       string `json:"Name"`
	Operator   bool   `json:"operator"`
	Accepted   bool   `json:"accepted"`
	Online     bool   `json:"online"`
	Permission string `json:"permission"`
}

Player is a player in a Realm.

type Realm

type Realm struct {
	// ID is the unique id for this realm.
	ID int `json:"id"`
	// RemoteSubscriptionID is The subscription ID of the realm.
	RemoteSubscriptionID string `json:"remoteSubscriptionID"`
	// Owner is always an empty string.
	Owner string `json:"owner"`
	// OwnerUUID is the XboxUserID (XUID) of the owner.
	OwnerUUID string `json:"ownerUUID"`
	// Name is the name of the Realm.
	Name string `json:"name"`
	// MOTD is always an empty string.
	MOTD string `json:"motd"`
	// DefaultPermission is the default permission level of the Realm world.
	// one of ["MEMBER", "OPERATOR"]
	DefaultPermission string `json:"defaultPermission"`
	// State is the current state of the realm
	// one of: ["OPEN", "CLOSED"]
	State string `json:"state"`
	// DaysLeft is the days remaining before renewal of the Realm as an integer.
	// (always 0 for Realms where the current user is not the owner)
	DaysLeft int `json:"daysLeft"`
	// Expired is whether the Realm has expired as a trial or not.
	Expired bool `json:"expired"`
	// ExpiredTrial is whether the Realm has expired as a trial or not.
	ExpiredTrial bool `json:"expiredTrial"`
	// GracePeriod is whether the Realm is in its grace period after expiry or not.
	GracePeriod bool `json:"gracePeriod"`
	// WorldType is the world type of the currently loaded world.
	WorldType string `json:"worldType"`
	// Players is a list of the players currently online in the realm
	// NOTE: this is only sent when directly requesting a realm.
	Players []Player `json:"players"`
	// MaxPlayers is how many player slots this realm has.
	MaxPlayers int `json:"maxPlayers"`
	// MinigameName is always null
	MinigameName string `json:"minigameName"`
	// MinigameID is always null
	MinigameID string `json:"minigameId"`
	// MinigameImage is always null
	MinigameImage string `json:"minigameImage"`
	// ActiveSlot is unused, always 1
	ActiveSlot int `json:"activeSlot"`
	// Slots is unused, always null
	Slots []struct{} `json:"slots"`
	// Member is Unknown, always false. (even when member or owner)
	Member bool `json:"member"`
	// ClubID is the ID of the associated Xbox Live club as an integer.
	ClubID int64 `json:"clubId"`
	// SubscriptionRefreshStatus is Unknown, always null.
	SubscriptionRefreshStatus struct{} `json:"subscriptionRefreshStatus"`
	// contains filtered or unexported fields
}

Realm is the realm structure returned from the api.

func (*Realm) Address

func (r *Realm) Address(ctx context.Context) (RealmAddress, error)

Address requests the address and protocol used to connect to this realm. It will wait for the realm to start if it is currently offline.

func (*Realm) OnlinePlayers

func (r *Realm) OnlinePlayers(ctx context.Context) (players []Player, err error)

OnlinePlayers gets all the players currently on this realm, Returns a 403 error if the current user is not the owner of the Realm.

type RealmAddress added in v1.55.2

type RealmAddress struct {
	Address           string          `json:"address"`
	NetworkProtocol   NetworkProtocol `json:"networkProtocol"`
	PendingUpdate     bool            `json:"pendingUpdate"`
	SessionRegionData struct {
		RegionName     string `json:"regionName"`
		ServiceQuality int    `json:"serviceQuality"`
	} `json:"sessionRegionData"`
}

RealmAddress contains the address returned by the Realms join endpoint along with the signalling protocol used for connecting to it.

Jump to

Keyboard shortcuts

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