Documentation
¶
Index ¶
- Constants
- type ActivityFilter
- type ActivityHandle
- type ActivityHandleRelatedInfo
- type Commit
- type Handler
- type InviteHandle
- type JoinConfig
- type MemberConstants
- type MemberConstantsSystem
- type MemberDescription
- type MemberInitialization
- type MemberProperties
- type MemberPropertiesSystem
- type MemberPropertiesSystemSubscription
- type NopHandler
- type PeerToHostRequirements
- type PeerToPeerRequirements
- type PublishConfig
- type Query
- type Session
- type SessionCapabilities
- type SessionConstants
- type SessionConstantsSystem
- type SessionConstantsSystemMetrics
- type SessionDescription
- type SessionProperties
- type SessionPropertiesSystem
- type SessionPropertiesSystemMatchmaking
- type SessionReference
Constants ¶
const ( ChangeTypeEverything = "everything" ChangeTypeHost = "host" ChangeTypeInitialization = "initialization" ChangeTypeMatchmakingStatus = "matchmakingStatus" ChangeTypeMembersList = "membersList" ChangeTypeMembersStatus = "membersStatus" ChangeTypeJoinability = "joinability" ChangeTypeCustomProperty = "customProperty" ChangeTypeMembersCustomProperty = "membersCustomProperty" )
const ( SessionRestrictionNone = "none" SessionRestrictionLocal = "local" SessionRestrictionFollowed = "followed" )
const ( HostSelectionMetricBandwidthUp = "bandwidthUp" HostSelectionMetricBandwidthDown = "bandwidthDown" HostSelectionMetricBandwidth = "bandwidth" HostSelectionMetricLatency = "latency" )
const ( SessionVisibilityPrivate = "private" SessionVisibilityVisible = "visible" SessionVisibilityOpen = "open" )
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 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 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 PeerToPeerRequirements ¶
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 ¶
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) Commit ¶
Commit pushes a SessionDescription into the session, updating properties and other fields on the service.
func (*Session) Handle ¶
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.
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"`
}