mpsd

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: 2

Documentation

Index

Constants

View Source
const (
	ChangeTypeEverything            = "everything"
	ChangeTypeHost                  = "host"
	ChangeTypeInitialization        = "initialization"
	ChangeTypeMatchmakingStatus     = "matchmakingStatus"
	ChangeTypeMembersList           = "membersList"
	ChangeTypeMembersStatus         = "membersStatus"
	ChangeTypeJoinability           = "joinability"
	ChangeTypeCustomProperty        = "customProperty"
	ChangeTypeMembersCustomProperty = "membersCustomProperty"
)
View Source
const (
	SessionRestrictionNone     = "none"
	SessionRestrictionLocal    = "local"
	SessionRestrictionFollowed = "followed"
)
View Source
const (
	HostSelectionMetricBandwidthUp   = "bandwidthUp"
	HostSelectionMetricBandwidthDown = "bandwidthDown"
	HostSelectionMetricBandwidth     = "bandwidth"
	HostSelectionMetricLatency       = "latency"
)
View Source
const (
	SessionVisibilityPrivate = "private"
	SessionVisibilityVisible = "visible"
	SessionVisibilityOpen    = "open"
)
View Source
const (
	SocialGroupPeople = "people"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivityFilter

type ActivityFilter struct {
	// Client is a [http.Client] to be used to do HTTP requests. If nil, http.DefaultClient will be copied.
	Client *http.Client

	// SocialGroup specifies a group that contains handles of activities.
	SocialGroup string
	// SocialGroupXUID references a user that does searching on specific SocialGroup.
	SocialGroupXUID string
}

An ActivityFilter specifies a filter applied for searching activities on ActivityFilter.Search

func (ActivityFilter) Search

func (f ActivityFilter) Search(src xsapi.TokenSource, serviceConfigID uuid.UUID) ([]ActivityHandle, error)

type ActivityHandle

type ActivityHandle struct {
	CreateTime       time.Time                  `json:"createTime,omitempty"`
	CustomProperties json.RawMessage            `json:"customProperties,omitempty"`
	GameTypes        json.RawMessage            `json:"gameTypes,omitempty"`
	ID               uuid.UUID                  `json:"id,omitempty"`
	InviteProtocol   string                     `json:"inviteProtocol,omitempty"`
	RelatedInfo      *ActivityHandleRelatedInfo `json:"relatedInfo,omitempty"`
	TitleID          string                     `json:"titleId,omitempty"`
	// contains filtered or unexported fields
}

type ActivityHandleRelatedInfo

type ActivityHandleRelatedInfo struct {
	Closed          bool      `json:"closed,omitempty"`
	InviteProtocol  string    `json:"inviteProtocol,omitempty"`
	JoinRestriction string    `json:"joinRestriction,omitempty"`
	MaxMembersCount uint32    `json:"maxMembersCount,omitempty"`
	PostedTime      time.Time `json:"postedTime,omitempty"`
	Visibility      string    `json:"visibility,omitempty"`
}

type Commit

type Commit struct {
	ContractVersion uint32    `json:"contractVersion,omitempty"`
	CorrelationID   uuid.UUID `json:"correlationId,omitempty"`
	SearchHandle    uuid.UUID `json:"searchHandle,omitempty"`
	Branch          uuid.UUID `json:"branch,omitempty"`
	ChangeNumber    uint64    `json:"changeNumber,omitempty"`
	StartTime       time.Time `json:"startTime,omitempty"`
	NextTimer       time.Time `json:"nextTimer,omitempty"`

	*SessionDescription
}

Commit includes a SessionDescription returned as a response body from the service. It can be retrieved on Session.Query, Query, and Session.Commit.

type Handler

type Handler interface {
	// HandleSessionChange handles a change of session. The latest state of Session can be
	// retrieved via [Session.Query].
	HandleSessionChange(ref SessionReference, branch uuid.UUID, changeNumber uint64)
}

Handler notifies that a Session has been changed. It is called by the handler of *rta.Subscription contracted with *rta.Conn on PublishConfig.PublishContext.

type InviteHandle

type InviteHandle struct {
	Expiration     time.Time       `json:"expiration,omitempty"`
	ID             uuid.UUID       `json:"id,omitempty"`
	InviteProtocol string          `json:"inviteProtocol,omitempty"`
	SenderXUID     string          `json:"senderXuid,omitempty"`
	GameTypes      json.RawMessage `json:"gameTypes,omitempty"`
	// contains filtered or unexported fields
}

type JoinConfig

type JoinConfig struct {
	PublishConfig
}

JoinConfig implements methods for joining a Session from several handles. It also includes a PublishConfig to publish a SessionDescription into the URL referenced in a handle.

func (JoinConfig) JoinActivityContext

func (conf JoinConfig) JoinActivityContext(ctx context.Context, src xsapi.TokenSource, handle ActivityHandle) (*Session, error)

JoinActivityContext joins a Session from ActivityHandle.

func (JoinConfig) JoinHandleContext

func (conf JoinConfig) JoinHandleContext(ctx context.Context, src xsapi.TokenSource, handleID uuid.UUID, ref SessionReference) (*Session, error)

JoinHandleContext joins a Session from the ID of handle and a reference to it.

type MemberConstants

type MemberConstants struct {
	System *MemberConstantsSystem `json:"system,omitempty"`
	// Custom is a JSON string that specify the custom constants for the member.
	Custom json.RawMessage `json:"custom,omitempty"`
}

type MemberConstantsSystem

type MemberConstantsSystem struct {
	// XUID is the user ID of the member. Only known if the member has accepted.
	XUID       string `json:"xuid,omitempty"`
	Initialize bool   `json:"initialize,omitempty"`
}

type MemberDescription

type MemberDescription struct {
	Constants  *MemberConstants  `json:"constants,omitempty"`
	Properties *MemberProperties `json:"properties,omitempty"`
	Roles      json.RawMessage   `json:"roles,omitempty"`
}

MemberDescription represents a read only reference to member in a multiplayer session.

type MemberInitialization

type MemberInitialization struct {
	JoinTimeout          uint64 `json:"joinTimeout,omitempty"`
	MeasurementTimeout   uint64 `json:"measurementTimeout,omitempty"`
	EvaluationTimeout    uint64 `json:"evaluationTimeout,omitempty"`
	ExternalEvaluation   bool   `json:"externalEvaluation,omitempty"`
	MembersNeededToStart uint32 `json:"membersNeededToStart,omitempty"`
}

type MemberProperties

type MemberProperties struct {
	System *MemberPropertiesSystem `json:"system,omitempty"`
	Custom json.RawMessage         `json:"custom,omitempty"`
}

type MemberPropertiesSystem

type MemberPropertiesSystem struct {
	Active              bool                                `json:"active,omitempty"`
	Ready               bool                                `json:"ready,omitempty"`
	Connection          uuid.UUID                           `json:"connection,omitempty"`
	Subscription        *MemberPropertiesSystemSubscription `json:"subscription,omitempty"`
	SecureDeviceAddress []byte                              `json:"secureDeviceAddress,omitempty"`
	InitializationGroup []uint32                            `json:"initializationGroup,omitempty"`
	Groups              []string                            `json:"groups,omitempty"`
	Encounters          []string                            `json:"encounters,omitempty"`
	Measurements        json.RawMessage                     `json:"measurements,omitempty"`
	ServerMeasurements  json.RawMessage                     `json:"serverMeasurements,omitempty"`
}

type MemberPropertiesSystemSubscription

type MemberPropertiesSystemSubscription struct {
	ID string `json:"id,omitempty"`
	// ChangeTypes defines values that indicate change types for a multiplayer session.
	ChangeTypes []string `json:"changeTypes,omitempty"`
}

type NopHandler

type NopHandler struct{}

A NopHandler implements a no-op Handler, which does nothing.

func (NopHandler) HandleSessionChange

func (NopHandler) HandleSessionChange(SessionReference, uuid.UUID, uint64)

type PeerToHostRequirements

type PeerToHostRequirements struct {
	LatencyMaximum       uint64 `json:"latencyMaximum,omitempty"`
	BandwidthDownMinimum uint64 `json:"bandwidthDownMinimum,omitempty"`
	BandwidthUpMinimum   uint64 `json:"bandwidthUpMinimum,omitempty"`
	HostSelectionMetric  string `json:"hostSelectionMetric,omitempty"`
}

type PeerToPeerRequirements

type PeerToPeerRequirements struct {
	LatencyMaximum   uint64 `json:"latencyMaximum,omitempty"`
	BandwidthMinimum uint64 `json:"bandwidthMinimum,omitempty"`
}

type PublishConfig

type PublishConfig struct {
	RTADialer *rta.Dialer
	RTAConn   *rta.Conn

	Description *SessionDescription

	Client *http.Client
	Logger *slog.Logger
}

PublishConfig contains an options for publishing a SessionDescription into a Session.

func (PublishConfig) PublishContext

func (conf PublishConfig) PublishContext(ctx context.Context, src xsapi.TokenSource, ref SessionReference) (s *Session, err error)

PublishContext publishes a Session on the SessionReference using the context.Context.

type Query

type Query struct {
	Client *http.Client
}

func (Query) Query

func (q Query) Query(src xsapi.TokenSource, ref SessionReference) (*Commit, error)

Query retrieves the Commit of a session referenced in SessionReference.

type Session

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

func (*Session) Close

func (s *Session) Close() error

func (*Session) Commit

func (s *Session) Commit(ctx context.Context, d *SessionDescription) (*Commit, error)

Commit pushes a SessionDescription into the session, updating properties and other fields on the service.

func (*Session) Handle

func (s *Session) Handle(h Handler)

Handle stores a Handler into the Session atomically, which notifies events that may occur in the *rta.Subscription of the Session. If Handler is a nil, a NopHandler will be stored instead.

func (*Session) Invite

func (s *Session) Invite(xuid string, titleID int32) (*InviteHandle, error)

Invite sends an invitation into the user referenced by XUID. The ID of the title which has sent an invitation is required to call this method. An InviteHandle may be returned.

func (*Session) Query

func (s *Session) Query() (*Commit, error)

type SessionCapabilities

type SessionCapabilities struct {
	// Connectivity indicates whether a session can enable metrics.
	Connectivity bool `json:"connectivity,omitempty"`
	// If SuppressPresenceActivityCheck is false (the default value), active users are required to
	// remain online playing the title. If they don't, they are demoted to inactive status. Set
	// SuppressPresenceActivityCheck to true to enable session members to stay active indefinitely
	SuppressPresenceActivityCheck bool `json:"suppressPresenceActivityCheck,omitempty"`
	// Gameplay indicates whether the session represents actual gameplay rather than time in setup
	// or a menu, such as a lobby or during matchmaking.
	Gameplay bool `json:"gameplay,omitempty"`
	// If Large is true, if the session can host 101 to 1000 users, which affects other session features.
	// Otherwise, the session can host 1 to 100 users.
	Large bool `json:"large,omitempty"`
	// If UserAuthorizationStyle is true, the session supports calls from platforms without strong
	// title identity. This capability can't be set on large sessions.
	UserAuthorizationStyle bool `json:"userAuthorizationStyle,omitempty"`
	// If ConnectionRequiredForActiveMembers is true, a connection is required for a member to be
	// marked as active. To enable session notifications and detect disconnections, it must be set
	// to true.
	ConnectionRequiredForActiveMembers bool `json:"connectionRequiredForActiveMembers,omitempty"`
	// CrossPlay is true, if the session supports crossplay.
	CrossPlay bool `json:"crossPlay,omitempty"`
	// If Searchable is true, the session can be linked to a search handle for searching.
	Searchable bool `json:"searchable,omitempty"`
	// If HasOwners is true, the session has owners.
	HasOwners bool `json:"hasOwners,omitempty"`
}

SessionCapabilities represents the capabilities of multiplayer session.

SessionCapabilities are optional bool values that are set in the session template. If no capabilities are needed, an empty SessionCapabilities should be used in the template to prevent capabilities from being specified at session creation, unless the title requires dynamic session capabilities.

type SessionConstants

type SessionConstants struct {
	System *SessionConstantsSystem `json:"system,omitempty"`
	// Custom is any custom constants for the session, specified in a JSON string.
	Custom json.RawMessage `json:"custom,omitempty"`
}

SessionConstants represents constants for a multiplayer session.

SessionConstants are set by the creator or by the session template only when a session is created. Fields in SessionConstants generally cannot be changed after the session is created.

type SessionConstantsSystem

type SessionConstantsSystem struct {
	// MaxMembersCount is the maximum number of members in the session.
	MaxMembersCount uint32 `json:"maxMembersCount,omitempty"`
	// Capabilities is the capabilities of the session.
	Capabilities *SessionCapabilities `json:"capabilities,omitempty"`
	// Visibility is the visibility of the session.
	Visibility string `json:"visibility,omitempty"`
	// Initiators is a list of XUIDs indicating who initiated the session.
	Initiators []string `json:"initiators,omitempty"`
	// ReservedRemovalTimeout is the maximum time, in milliseconds, for a member with a reservation
	// to join the session. If the member doesn't join within this time, this reservation is removed.
	ReservedRemovalTimeout uint64 `json:"reservedRemovalTimeout,omitempty"`
	// InactiveRemovalTimeout is the maximum time, in milliseconds, for an inactive member to become
	// active. If an inactive member doesn't become active within this time, the member is removed from
	// the session.
	InactiveRemovalTimeout uint64 `json:"inactiveRemovalTimeout,omitempty"`
	// ReadyRemovalTimeout is the maximum time, in milliseconds, for a member who is marked as ready
	// to become active. When the shell launches the title to start a multiplayer game, the member is
	// marked as ready. If a member who is marked as ready doesn't become active with in this time,
	// the member becomes inactive.
	ReadyRemovalTimeout uint64 `json:"readyRemovalTimeout,omitempty"`
	// SessionEmptyTimeout is the maximum time, in milliseconds, that the session can remain empty.
	// If no members join the session within this time, the session is deleted.
	SessionEmptyTimeout uint64                         `json:"sessionEmptyTimeout,omitempty"`
	Metrics             *SessionConstantsSystemMetrics `json:"metrics,omitempty"`
	// If MemberInitialization is set, the session expects the client system or title to perform initialization
	// after session creation. Timeouts and initialization stages are automatically tracked by the session, including
	// initial Quality of Service (QoS) measurements if any metrics are set.
	MemberInitialization *MemberInitialization `json:"memberInitialization,omitempty"`
	// PeerToPeerRequirements is a QoS requirements for a connection between session members.
	PeerToPeerRequirements *PeerToPeerRequirements `json:"peerToPeerRequirements,omitempty"`
	// PeerToHostRequirements is a QoS requirements for a connection between a host candidate
	// and session members.
	PeerToHostRequirements *PeerToHostRequirements `json:"peerToHostRequirements,omitempty"`
	// MeasurementServerAddresses is the set of potential server connection strings that should
	// be evaluated.
	MeasurementServerAddresses json.RawMessage `json:"measurementServerAddresses,omitempty"`
	// CloudComputePackage is the Cloud Compute package constants for the session, specified in a JSON string.
	CloudComputePackage json.RawMessage `json:"cloudComputePackage,omitempty"`
}

type SessionConstantsSystemMetrics

type SessionConstantsSystemMetrics struct {
	// Latency indicates that the title wants latency measured to
	// help determine connectivity.
	Latency bool `json:"latency,omitempty"`
	// Bandwidth indicates that the title wants downstream (host-to-peer)
	// bandwidth measured to help determine connectivity.
	BandwidthDown bool `json:"bandwidthDown,omitempty"`
	// BandwidthUp indicates that the title wants upstream (peer-to-host)
	// bandwidth measured to help determine connectivity.
	BandwidthUp bool `json:"bandwidthUp,omitempty"`
	// Custom indicates that the title wants a custom measurement to help
	// determine connectivity.
	Custom bool `json:"custom,omitempty"`
}

type SessionDescription

type SessionDescription struct {
	Constants  *SessionConstants             `json:"constants,omitempty"`
	RoleTypes  json.RawMessage               `json:"roleTypes,omitempty"`
	Properties *SessionProperties            `json:"properties,omitempty"`
	Members    map[string]*MemberDescription `json:"members,omitempty"`
}

type SessionProperties

type SessionProperties struct {
	System *SessionPropertiesSystem `json:"system,omitempty"`
	// Custom is a JSON string that specify the custom properties for the session. These can
	// be changed anytime.
	Custom json.RawMessage `json:"custom,omitempty"`
}

SessionProperties is a set of properties associated with multiplayer session. Any member can modify these fields.

type SessionPropertiesSystem

type SessionPropertiesSystem struct {
	// Keywords is an optional list of keywords associated with the session.
	Keywords []string `json:"keywords,omitempty"`
	// Turn is a list of member IDs indicating whose turn it is.
	Turn []uint32 `json:"turn,omitempty"`
	// JoinRestriction restricts who can join "open" sessions. (Has no effects on reservations,
	// which means it has no impact on "private" and "visible" sessions)
	// It is one of constants defined below.
	JoinRestriction string `json:"joinRestriction,omitempty"`
	// ReadRestriction restricts who can read "open" sessions. (Has no effect on reservations,
	// which means it has no impact on "private" and "visible" sessions.)
	ReadRestriction string `json:"readRestriction,omitempty"`
	// Controls whether a session is joinable, independent of visibility, join restriction,
	// and available space in the session. Does not affect reservations. Defaults to false.
	Closed bool `json:"closed"`
	// If Locked is true, it would allow the members of the session to be locked, such that
	// if a user leaves they are able to come back into the session but no other user could
	// take that spot. Defaults to false.
	Locked      bool                                `json:"locked,omitempty"`
	Matchmaking *SessionPropertiesSystemMatchmaking `json:"matchmaking,omitempty"`
	// MatchmakingResubmit is true, if the match that was found didn't work out and needs to
	// be resubmitted. If false, signal that the match did work, and the matchmaking service
	// can release the session.
	MatchmakingResubmit bool `json:"matchmakingResubmit,omitempty"`
	// InitializationSucceeded is true if initialization succeeded.
	InitializationSucceeded bool `json:"initializationSucceeded,omitempty"`
	// Host is the device token of the host.
	Host string `json:"host,omitempty"`
	// ServerConnectionStringCandidates is the ordered list of case-insensitive connection
	// strings that the session could use to connect to a game server. Generally titles
	// should use the first on the list, but sophisticated titles could use a custom mechanism
	// for choosing one of the others (e.g. based on load).
	ServerConnectionStringCandidates json.RawMessage `json:"serverConnectionStringCandidates,omitempty"`
}

type SessionPropertiesSystemMatchmaking

type SessionPropertiesSystemMatchmaking struct {
	// TargetSessionConstants is a JSON string representing the target session constants.
	TargetSessionConstants json.RawMessage `json:"targetSessionConstants,omitempty"`
	// ServerConnectionString Force a specific connection string to be used. This is useful
	// for session in progress join scenarios.
	ServerConnectionString string `json:"serverConnectionString,omitempty"`
}

type SessionReference

type SessionReference struct {
	ServiceConfigID uuid.UUID `json:"scid,omitempty"`
	TemplateName    string    `json:"templateName,omitempty"`
	Name            string    `json:"name,omitempty"`
}

A SessionReference contains a reference to a Session.

func (SessionReference) URL

func (ref SessionReference) URL() *url.URL

URL returns the url.URL of the session referenced in SessionReference.

Jump to

Keyboard shortcuts

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