Documentation
¶
Index ¶
- Constants
- type AcceptedFriendRequests
- type Action
- type Actor
- type Client
- func (c *Client) Dismiss(ctx context.Context, notification Notification, opts ...internal.RequestOption) error
- func (c *Client) Inbox(ctx context.Context, filter InboxFilter, opts ...internal.RequestOption) ([]Notification, error)
- func (c *Client) MarkRead(ctx context.Context, notification Notification, opts ...internal.RequestOption) error
- func (c *Client) MarkSeen(ctx context.Context, notification Notification, opts ...internal.RequestOption) error
- func (c *Client) Update(ctx context.Context, notifications []Notification, typ string, ...) error
- type Followers
- type GameInvite
- type GameInviteAction
- type GameInviteLaunchInfo
- type GameInviteOptions
- type InboxFilter
- type IncomingFriendRequests
- type Location
- type Notification
- type Unknown
Constants ¶
const ( UpdateTypeLastSeen = "LastSeen" UpdateTypeLastRead = "LastRead" UpdateTypeLastDeleted = "LastDeleted" )
const ( SubscriptionCategoryMultiplayer = "Microsoft.Xbox.Multiplayer" SubscriptionCategoryPeople = "Microsoft.Xbox.People" )
const ( SubscriptionTypeGameInvite = "GameInvites" SubscriptionTypeFollowers = "Followers" SubscriptionTypeAcceptedFriendRequests = "AcceptedFriendRequests" SubscriptionTypeIncomingFriendRequests = "IncomingFriendRequests" )
const (
// ActorTypeUser indicates that an Actor is a user.
ActorTypeUser = 1
)
const (
// LocationTypeTitle indicates that the Location is a title.
LocationTypeTitle = 3
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcceptedFriendRequests ¶
type AcceptedFriendRequests struct {
// contains filtered or unexported fields
}
AcceptedFriendRequests represents a notification received when friend requests sent by the caller is accepted. Actor.ID in Actions identifies who the caller has become friends with.
func (*AcceptedFriendRequests) SubscriptionCategory ¶
func (n *AcceptedFriendRequests) SubscriptionCategory() string
SubscriptionCategory implements Notification.SubscriptionCategory.
func (*AcceptedFriendRequests) SubscriptionID ¶
func (n *AcceptedFriendRequests) SubscriptionID() string
SubscriptionID implements Notification.SubscriptionID.
func (*AcceptedFriendRequests) SubscriptionType ¶
func (n *AcceptedFriendRequests) SubscriptionType() string
SubscriptionType implements Notification.SubscriptionType.
func (*AcceptedFriendRequests) UnmarshalJSON ¶
UnmarshalJSON decodes the given JSON data into n with patches to support decoding payload received from WebSocket service.
type Action ¶
type Action struct {
// Actor is the user associated with this action.
// It is not necessarily the caller. For game invites, this represents the
// user who have sent the invite.
Actor Actor
// ActionID is the ID assigned to this action.
ActionID string `json:"ActionId"`
// Timestamp is the time at which this action was created.
Timestamp time.Time `json:"ActionTime"`
// Category is the subscription category of this action's parent notification.
Category string `json:"SubscriptionCategory"`
// Type is the subscription type of this action's parent notification.
Type string `json:"SubscriptionType"`
// ID is the subscription ID of this action's parent notification.
ID string `json:"SubscriptionId"`
}
Action represents an action that can be taken on a notification.
type Actor ¶
type Actor struct {
// ClassicGamerTag is the user's display name.
ClassicGamerTag string `json:"ClassicGamertag"`
// ModernGamerTag is the base portion of a modern gamertag, excluding
// the numeric suffix.
ModernGamerTag string `json:"ModernGamertag"`
// ModernGamerTagSuffix is the numeric suffix of a modern gamertag,
// without the hash character.
ModernGamerTagSuffix string `json:"ModernGamertagSuffix"`
// UniqueModernGamerTag is the fully qualified modern gamertag in the
// format "[Actor.ModernGamerTag]#[Actor.ModernGamerTagSuffix]".
UniqueModernGamerTag string `json:"UniqueModernGamertag"`
// Name is the name of the actor.
Name string
// ID is the unique ID assigned to this actor.
// When [Actor.Type] is [ActorTypeUser], this is the XUID of the user.
ID string `json:"Id"`
// Type indicates the type of the Actor.
// It is one of the constants below.
Type int
}
Actor represents the user or entity associated with an Action.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements an API Client for Xbox Live Notification API.
func (*Client) Dismiss ¶
func (c *Client) Dismiss(ctx context.Context, notification Notification, opts ...internal.RequestOption) error
Dismiss dismisses the given notification. The notification will no longer be included in the result of subsequent callers to Client.Inbox.
func (*Client) Inbox ¶
func (c *Client) Inbox(ctx context.Context, filter InboxFilter, opts ...internal.RequestOption) ([]Notification, error)
Inbox returns the caller's notification inbox. The filter may be used to limit which notifications are populated in the result.
func (*Client) MarkRead ¶
func (c *Client) MarkRead(ctx context.Context, notification Notification, opts ...internal.RequestOption) error
MarkRead marks the given notification as read. [Notification.MarkedRead] may be set to true the next time this notification is retrieved. If the notification is later updated, MarkedRead reverts to false, so this method must be called again to mark it as read once more. It is unclear how this differs from Client.MarkSeen.
func (*Client) MarkSeen ¶
func (c *Client) MarkSeen(ctx context.Context, notification Notification, opts ...internal.RequestOption) error
MarkSeen marks the given notification as seen. [Notification.Seen] may be set to true the next time this notification is retrieved. If the notification is later updated, Seen reverts to false, so this method must be called again to mark it as seen once more. It is unclear how this differs from Client.MarkRead.
func (*Client) Update ¶
func (c *Client) Update(ctx context.Context, notifications []Notification, typ string, timestamp time.Time, opts ...internal.RequestOption) error
Update updates the given notifications with the given update type and the timestamp. The type must be one of the UpdateType constants defined below. The timestamp records when the update occurred and is used to determine which notifications have unread updates.
type Followers ¶
type Followers struct {
// contains filtered or unexported fields
}
Followers represents a notification received when the caller is followed by someone.
func (*Followers) SubscriptionCategory ¶
func (n *Followers) SubscriptionCategory() string
SubscriptionCategory implements Notification.SubscriptionCategory.
func (*Followers) SubscriptionID ¶
func (n *Followers) SubscriptionID() string
SubscriptionID implements Notification.SubscriptionID.
func (*Followers) SubscriptionType ¶
func (n *Followers) SubscriptionType() string
SubscriptionType implements Notification.SubscriptionType.
func (*Followers) UnmarshalJSON ¶
UnmarshalJSON decodes the given JSON data into n with patches to support decoding payload received from WebSocket service.
type GameInvite ¶
type GameInvite struct {
// Options contains options for launching/activating a title with the
// invitation.
Options GameInviteOptions `json:"NotificationOptions"`
// contains filtered or unexported fields
}
GameInvite represents a notification received when the caller is invited to a game. The caller can join the multiplayer session by using the HandleID contained in its Actions.
func (*GameInvite) SubscriptionCategory ¶
func (n *GameInvite) SubscriptionCategory() string
SubscriptionCategory implements Notification.SubscriptionCategory.
func (*GameInvite) SubscriptionID ¶
func (n *GameInvite) SubscriptionID() string
SubscriptionID implements Notification.SubscriptionID.
func (*GameInvite) SubscriptionType ¶
func (n *GameInvite) SubscriptionType() string
SubscriptionType implements Notification.SubscriptionType.
func (*GameInvite) UnmarshalJSON ¶
UnmarshalJSON decodes the given JSON data into n with patches to support decoding payload received from WebSocket service.
type GameInviteAction ¶
type GameInviteAction struct {
Action
// LaunchInfo contains information for launching/activating the title with the invite.
LaunchInfo GameInviteLaunchInfo
}
GameInviteAction represents an action that can be taken on a GameInvite notification.
type GameInviteLaunchInfo ¶
type GameInviteLaunchInfo struct {
// HandleID is the ID corresponding to a handle within the
// Multiplayer Session Directory (MPSD). Callers can use this ID as the second
// parameter for [github.com/df-mc/go-xsapi/v2/mpsd.Client.Join] to join the multiplayer
// session from the invitation.
HandleID uuid.UUID `json:"mpsdHandleId"`
// ExpirationTime indicates the time at which the handle identified
// by [GameInviteLaunchInfo.HandleID] will expire.
ExpirationTime time.Time `json:"expirationTime"`
// GameTypes is a map whose keys are platform name such as "uwp-desktop" or
// "android", and whose values are structs that describes a single title
// associated with the invite handle.
GameTypes map[string]mpsd.GameType `json:"gameTypes"`
}
GameInviteLaunchInfo holds the parameter required to launch the title and join the multiplayer session from a GameInviteAction.
func (*GameInviteLaunchInfo) UnmarshalJSON ¶
func (i *GameInviteLaunchInfo) UnmarshalJSON(b []byte) error
UnmarshalJSON decodes the given JSON data into GameInviteLaunchInfo.
type GameInviteOptions ¶
type GameInviteOptions struct {
// Location describes the title ta which the invite could be accepted.
// To accept invitations for a specific title only, filter [Location.ID]
// by the title ID.
Location Location
// Platforms lists the platforms supported by the game.
Platforms []string
}
GameInviteOptions represents the options for a GameInvite notification.
type InboxFilter ¶
type InboxFilter struct {
// MaxItems specifies the maximum amount of notifications that can
// be included in the result. When zero, it will be set to 200.
MaxItems int
// MaxActions specifies the maximum amount of actions that can be
// embedded to each notification included in the result. When zero,
// it wil be set to 5.
MaxActions int
// SubscriptionCategories specifies the list of subscription categories
// that will be populated in the result. If empty, the categories
// supported in this package are used instead.
SubscriptionCategories []string
// SubscriptionTypes specifies the list of subscription types that will
// be populated in the result. If empty, all subscription types supported
// in this package are used instead.
SubscriptionTypes []string
}
InboxFilter represents a filter used for retrieving the notification inbox for the caller.
type IncomingFriendRequests ¶
type IncomingFriendRequests struct {
// contains filtered or unexported fields
}
IncomingFriendRequests represents a notification received when the caller receives friend requests from someone. Actor.ID in Actions identifies who sent the friend request.
func (*IncomingFriendRequests) SubscriptionCategory ¶
func (n *IncomingFriendRequests) SubscriptionCategory() string
SubscriptionCategory implements Notification.SubscriptionCategory.
func (*IncomingFriendRequests) SubscriptionID ¶
func (n *IncomingFriendRequests) SubscriptionID() string
SubscriptionID implements Notification.SubscriptionID.
func (*IncomingFriendRequests) SubscriptionType ¶
func (n *IncomingFriendRequests) SubscriptionType() string
SubscriptionType implements Notification.SubscriptionType.
func (*IncomingFriendRequests) UnmarshalJSON ¶
UnmarshalJSON decodes the given JSON data into n with patches to support decoding payload received from WebSocket service.
type Location ¶
type Location struct {
// PackageFamilyName is the package family name of the title.
// It is only populated when [Location.Type] is [LocationTypeTitle].
PackageFamilyName string `json:"Pfn"`
// DisplayImage is the URL used as the thumbnail for the title.
// It is only populated when [Location.Type] is [LocationTypeTitle].
DisplayImage string
// Name is the name of the location.
Name string
// ID is the unique ID assigned to this Location.
// When [Location.Type] is [LocationTypeTitle], this represents the title ID.
ID string `json:"Id"`
// Type indicates the type of the location.
// It is one of the constants below.
Type int
}
Location represents the location at which an action would be invoked.
type Notification ¶
type Notification interface {
// SubscriptionCategory returns the subscription category of the notification/action.
// It is one of the constants below.
SubscriptionCategory() string
// SubscriptionType returns the subscription type of the notification/action.
// It is one of the constants below.
SubscriptionType() string
// SubscriptionID returns the subscription ID of the notification/action.
SubscriptionID() string
}
Notification represents a notification received from Xbox Live.
The following types implement this interface: - GameInvite - Followers - IncomingFriendRequests - AcceptedFriendRequests
func Unmarshal ¶
func Unmarshal(b []byte) (Notification, error)
Unmarshal decodes the given JSON data into a Notification.
type Unknown ¶
type Unknown struct {
// Category is the subscription category of the notification.
Category string `json:"SubscriptionCategory"`
// Type is the subscription type of the notification.
Type string `json:"SubscriptionType"`
// ID is the subscription ID of the notification.
ID string `json:"SubscriptionId"`
// Raw is the raw JSON data that were passed to [Unmarshal].
Raw json.RawMessage `json:"-"`
}
Unknown is returned by Unmarshal when the given notification are not supported by this package. Callers can decode the raw JSON data contained in Unknown.Raw into their own representation.
func (*Unknown) SubscriptionCategory ¶
SubscriptionCategory implements Notification.SubscriptionCategory.
func (*Unknown) SubscriptionID ¶
SubscriptionID implements Notification.SubscriptionID.
func (*Unknown) SubscriptionType ¶
SubscriptionType implements Notification.SubscriptionType.