Invitations
Overview​
With the help of invites, you can manage the addition of players to the channel. Since you can implement chats, guilds, lobbies and much more on the basis of channels, invites become an integral part of them and provide the mechanism for joining somewhere. For example, a player may be asked to join a:
- group or team
- raid
- guild or clan
- community and so on
The mechanics of invites 💡 may be as follows: when a player is going to be invited somewhere, a flashing icon appears in the center of the screen with a proposal to join a chat, group, or raid and basic information about this event. In this case, the player can accept the offer, refuse, ignore, etc.
The mechanics of invites 💡 is given as an example. The SpellSync service does not visually display anything, but the developer can implement it on his own
The following is a complete list of methods implemented to manage invites in channels:
ss.channels.sendInvite
- sending an invitation +1Â Requestss.channels.cancelInvite
- cancel sending invitation +1Â Requestss.channels.acceptInvite
- accepting an invitation +1Â Requestss.channels.rejectInvite
- rejection of an invitation +1Â Requestss.channels.fetchInvites
- get a list of invitations to the channel +1Â Requestss.channels.fetchMoreInvites
- additionally load the list of invitations to the channel +1Â Requestss.channels.fetchChannelInvites
- get a list of invitations sent from a channel +1Â Requestss.channels.fetchMoreChannelInvites
- additionally load the list of invitations sent from the channel +1Â Requestss.channels.fetchSentInvites
- get a list of invitations sent from current player +1Â Requestss.channels.fetchMoreSentInvites
- additionally load the list of invitations sent from current player +1Â Request
Sending an Invitation​
+1Â RequestTo send an invite to a player playerId: 123456
in a channel channelId: 123
:
- JavaScript
- Unity
ss.channels.sendInvite({ channelId: 123, playerId: 123456 })
SS_Channels.SendInvite(channel_ID: 123, player_ID: 123456);
To get the result of a method call, you can subscribe to events:
- JavaScript
- Unity
ss.channels.on('sendInvite', () => {
// Invitation sent
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnSendInvite += OnSendInvite;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnSendInvite -= OnSendInvite;
}
// Invitation sent
private void OnSendInvite() => Debug.Log("ON SEND INVITE");
Execution with error:
- JavaScript
- Unity
ss.channels.on('error:sendInvite', (err) => {
// completed with an error
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnSendInviteError += OnSendInviteError;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnSendInviteError -= OnSendInviteError;
}
// completed with an error
private void OnSendInviteError() => Debug.Log("SEND INVITE: ERROR");
Possible errors are shown in the table below:
Basic Errors | Script Errors |
---|---|
player_not_found | not_invited |
project_not_found | empty_channel_id |
origin_not_allowed | channel_not_found |
player_banned | access_denied |
internal_error | already_in_channel |
already_invited |
The invited player receives an invitation. Other players (if they can invite other players) receive a notification that the player has been sent an invitation:
- JavaScript
- Unity
ss.channels.on('event:invite', (invite) => {
// Channel ID
invite.channelId
// ID of the player who sent the invitation
invite.playerFromId
// Player ID who was invited to
invite.playerToId
// The date the invitation was sent in the format ISO 8601 UTC "2022-12-01T04:52:26+0000"
invite.date
if (invite.playerToId === ss.player.id) {
// Invited me to the channel
} else {
// In the channel, someone sent someone an invitation
}
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnInvite += OnInvite;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnInvite -= OnInvite;
}
private void OnInvite(InviteData invite)
{
// Channel ID
Debug.log(invite.channelId);
// ID of the player who sent the invitation
Debug.log(invite.playerFromId);
// Player ID who was invited to
Debug.log(invite.playerToId);
// The date the invitation was sent in the format ISO 8601 UTC "2022-12-01T04:52:26+0000"
Debug.log(invite.date);
if (invite.playerToId === ss.player.id) {
// Invited me to the channel
} else {
// In the channel, someone sent someone an invitation
}
}
Cancel Sending an Invitation​
+1Â RequestTo cancel sending an invitation to a player playerId: 123456
in a channel channelId: 123
:
- JavaScript
- Unity
ss.channels.cancelInvite({ channelId: 123, playerId: 123456 })
SS_Channels.CancelInvite(channel_ID: 123, player_ID: 123456);
To get the result of a method call, you can subscribe to events:
- JavaScript
- Unity
ss.channels.on('cancelInvite', () => {
// Invitation sent
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnCancelInviteSuccess += OnCancelInviteSuccess;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnCancelInviteSuccess -= OnCancelInviteSuccess;
}
// Invitation sent
private void OnCancelInviteSuccess() => Debug.Log("CANCEL INVITE: SUCCESS");
Execution with error:
- JavaScript
- Unity
ss.channels.on('error:cancelInvite', (err) => {
// completed with an error
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnCancelInviteError += OnCancelInviteError;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnCancelInviteError -= OnCancelInviteError;
}
// completed with an error
private void OnCancelInviteError() => Debug.Log("CANCEL INVITE: ERROR");
Possible errors are shown in the table below:
Basic Errors | Script Errors |
---|---|
player_not_found | not_invited |
project_not_found | empty_channel_id |
origin_not_allowed | channel_not_found |
player_banned | access_denied |
internal_error | not_invited |
The invited player receives the cancellation of the invite. Other players (if they can invite other players) receive a notification that the invitation has been cancelled:
- JavaScript
- Unity
ss.channels.on('event:cancelInvite', (invite) => {
// Channel ID
invite.channelId
// ID of the player who sent the invitation
invite.playerFromId
// Player ID who was invited to
invite.playerToId
if (invite.playerToId === ss.player.id) {
// The invite sent to me was canceled
} else {
// In my channel, someone canceled the sent invite
}
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnCancelInviteEvent += OnCancelInviteEvent;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnCancelInviteEvent -= OnCancelInviteEvent;
}
private void OnCancelInviteEvent(CancelInviteData data)
{
Debug.Log("CANCEL INVITE EVENT: CHANNEL ID: " + data.channelId);
Debug.Log("CANCEL INVITE EVENT: PLAYER FROM: ID: " + data.playerFromId);
Debug.Log("CANCEL INVITE EVENT: PLAYER TO: ID: " + data.playerToId);
}
Accepting an Invitation​
+1Â RequestThe player can accept the invitation to the channel channelId: 123
:
- JavaScript
- Unity
ss.channels.acceptInvite({ channelId: 123 })
SS_Channels.AcceptInvite(channel_ID: 123);
After that, the player enters the channel. To get the result of a method call, you can subscribe to events:
- JavaScript
- Unity
ss.channels.on('acceptInvite', () => {
// successfully accepted
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnAcceptInvite += OnAcceptInvite;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnAcceptInvite -= OnAcceptInvite;
}
private void OnAcceptInvite() => Debug.Log("ON ACCEPT INVITE");
Execution with error:
- JavaScript
- Unity
ss.channels.on('error:acceptInvite', (err) => {
// completed with an error
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnAcceptInviteError += OnAcceptInviteError;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnAcceptInviteError -= OnAcceptInviteError;
}
private void OnAcceptInviteError() => Debug.Log("ACCEPT INVITE: ERROR");
Possible errors are shown in the table below:
Basic Errors | Script Errors |
---|---|
player_not_found | not_invited |
project_not_found | empty_channel_id |
origin_not_allowed | channel_not_found |
player_banned | already_in_channel |
internal_error | channel_capacity_reached |
When joining a channel, the invited player and all players in the channel receive a notification about joining:
- JavaScript
- Unity
ss.channels.on('event:join', (member) => {
// Channel ID
member.channelId
// Joined Player ID
member.id
// Player Fields (avatar, name, custom fields)
member.state
// Player Mute Information
member.mute
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnJoinEvent += OnJoinEvent;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnJoinEvent -= OnJoinEvent;
}
private void OnJoinEvent(SS_Data data)
{
var joinData = data.Get<JoinData>();
Debug.Log("JOIN EVENT: CHANNEL ID: " + joinData.channelId);
Debug.Log("JOIN EVENT: ID: " + joinData.id);
Debug.Log("JOIN EVENT: MUTE: IS MUTED: " + joinData.mute.isMuted);
Debug.Log("JOIN EVENT: MUTE: UNMUTE AT: " + joinData.mute.unmuteAt);
Debug.Log("JOIN EVENT: PLAYER STATE: AVATAR: " + joinData.state.avatar);
Debug.Log("JOIN EVENT: PLAYER STATE: CREDITIALS: " + joinData.state.credentials);
Debug.Log("JOIN EVENT: PLAYER STATE: ID: " + joinData.state.id);
Debug.Log("JOIN EVENT: PLAYER STATE: NAME: " + joinData.state.name);
Debug.Log("JOIN EVENT: PLAYER STATE: PLATFORM TYPE: " + joinData.state.platformType);
Debug.Log("JOIN EVENT: PLAYER STATE: PROJECT ID: " + joinData.state.projectId);
Debug.Log("JOIN EVENT: PLAYER STATE: SCORE: " + joinData.state.score);
}
Rejecting an Invitation​
+1Â RequestPlayer can decline invite from channelId: 123
:
- JavaScript
- Unity
ss.channels.rejectInvite({ channelId: 123 })
SS_Channels.RejectInvite(channel_ID: 123);
To get the result of a method call, you can subscribe to events:
- JavaScript
- Unity
ss.channels.on('rejectInvite', () => {
// successfully rejected
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnRejectInviteSuccess += OnRejectInviteSuccess;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnRejectInviteSuccess -= OnRejectInviteSuccess;
}
private void OnRejectInviteSuccess() => Debug.Log("REJECT INVITE: SUCCESS");
Execution with error:
- JavaScript
- Unity
ss.channels.on('error:rejectInvite', (err) => {
// completed with an error
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnRejectInviteError += OnRejectInviteError;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnRejectInviteError -= OnRejectInviteError;
}
private void OnRejectInviteError() => Debug.Log("REJECT INVITE: ERROR");
Possible errors are shown in the table below:
Basic Errors | Script Errors |
---|---|
player_not_found | not_invited |
project_not_found | empty_channel_id |
origin_not_allowed | channel_not_found |
player_banned | |
internal_error |
All players in the channel (if they can invite other players) receive a notification that the invitation has been cancelled:
- JavaScript
- Unity
ss.channels.on('event:rejectInvite', (invite) => {
// Channel ID
invite.channelId
// ID of the player who sent the invitation
invite.playerFromId
// ID of the player who was invited
invite.playerToId
if (invite.playerFromId === ss.player.id) {
// My invite was rejected
} else {
// Someone declined the sent invitation
}
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnRejectInviteEvent += OnRejectInviteEvent;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnRejectInviteEvent -= OnRejectInviteEvent;
}
private void OnRejectInviteEvent(RejectInviteData data)
{
Debug.Log("REJECT INVITE EVENT: CHANNEL ID: " + data.channelId);
Debug.Log("REJECT INVITE EVENT: PLAYER FROM: ID: " + data.playerFromId);
Debug.Log("REJECT INVITE EVENT: PLAYER TO: ID: " + data.playerToId);
}
Get a List of Player Invitations to Channels​
+1Â RequestWith the ss.channels.fetchInvites
method, you can get a list of all channels that a player has been invited to:
- JavaScript
- Unity
const response = await ss.channels.fetchInvites({
// how much to request at a time, max. 100
limit: 100,
// how many entries to skip, max. 10000, used for page navigation or "load more"
offset: 0
})
// limit - how much to request at a time, max. 100
// offset - how many entries to skip, max. 10000, used for page navigation or "load more"
SS_Channels.FetchInvites(limit: 100, offset: 0);
To get the result of a method call, you can subscribe to events:
- JavaScript
- Unity
ss.channels.on('fetchInvites', (result) => {
result.items // array of list of invites
result.canLoadMore // is it possible to upload more invites
result.items.forEach((invite) => {
// all fields of the invite
// fields of the channel to which the player is invited
invite.channel
invite.channel.id
invite.channel.tags
invite.channel.projectId
invite.channel.capacity
invite.channel.ownerId
invite.channel.name
invite.channel.description
invite.channel.private
invite.channel.visible
invite.channel.hasPassword
invite.channel.membersCount
// Public fields of the player who invites
invite.playerFrom
invite.playerFrom.id
invite.playerFrom.name
invite.playerFrom.avatar
// and other public fields
// date the invitation was sent, ISO 8601
invite.date
})
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnFetchInvites += OnFetchInvites;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnFetchInvites -= OnFetchInvites;
}
private void OnFetchInvites(SS_Data data, bool canLoadMore)
{
var fetchInvitesData = data.GetList<FetchInvitesData>();
Debug.Log("FETCH INVITES: CAN LOAD MORE: " + canLoadMore);
for (int i = 0; i < fetchInvitesData.Count; i++)
{
Debug.Log("FETCH INVITES: CHANNEL: ID: " + fetchInvitesData[i].channel.id);
for (int x = 0; x < fetchInvitesData[i].channel.tags.Length; x++)
{
Debug.Log("FETCH INVITES: CHANNEL: TAGS: " + fetchInvitesData[i].channel.tags[x]);
}
for (int a = 0; a < fetchInvitesData[i].channel.messageTags.Length; a++)
{
Debug.Log("FETCH INVITES: CHANNEL: MESSAGE TAGS: " + fetchInvitesData[i].channel.messageTags[a]);
}
Debug.Log("FETCH INVITES: CHANNEL: TEMPLATE ID: " + fetchInvitesData[i].channel.templateId);
Debug.Log("FETCH INVITES: CHANNEL: PROJECT ID: " + fetchInvitesData[i].channel.projectId);
Debug.Log("FETCH INVITES: CHANNEL: CAPACITY: " + fetchInvitesData[i].channel.capacity);
Debug.Log("FETCH INVITES: CHANNEL: OWNER ID: " + fetchInvitesData[i].channel.ownerId);
Debug.Log("FETCH INVITES: CHANNEL: NAME: " + fetchInvitesData[i].channel.name);
Debug.Log("FETCH INVITES: CHANNEL: DESCRIPTION: " + fetchInvitesData[i].channel.description);
Debug.Log("FETCH INVITES: CHANNEL: PRIVATE: " + fetchInvitesData[i].channel.ch_private);
Debug.Log("FETCH INVITES: CHANNEL: VISIBLE: " + fetchInvitesData[i].channel.visible);
Debug.Log("FETCH INVITES: CHANNEL: PERMANENT: " + fetchInvitesData[i].channel.permanent);
Debug.Log("FETCH INVITES: CHANNEL: HAS PASSWORD: " + fetchInvitesData[i].channel.hasPassword);
Debug.Log("FETCH INVITES: CHANNEL: PASSWORD: " + fetchInvitesData[i].channel.password);
Debug.Log("FETCH INVITES: CHANNEL: IS JOINED: " + fetchInvitesData[i].channel.isJoined);
Debug.Log("FETCH INVITES: CHANNEL: IS INVITED: " + fetchInvitesData[i].channel.isInvited);
Debug.Log("FETCH INVITES: CHANNEL: IS MUTED: " + fetchInvitesData[i].channel.isMuted);
Debug.Log("FETCH INVITES: CHANNEL: IS REQUEST SENT: " + fetchInvitesData[i].channel.isRequestSent);
Debug.Log("FETCH INVITES: CHANNEL: MEMBERS COUNT: " + fetchInvitesData[i].channel.membersCount);
Debug.Log("FETCH INVITES: CHANNEL: OWNER ACL: " + JsonUtility.ToJson(fetchInvitesData[i].channel.ownerAcl));
Debug.Log("FETCH INVITES: CHANNEL: MEMBER ACL: " + JsonUtility.ToJson(fetchInvitesData[i].channel.memberAcl));
Debug.Log("FETCH INVITES: CHANNEL: GUEST ACL: " + JsonUtility.ToJson(fetchInvitesData[i].channel.guestAcl));
Debug.Log("FETCH INVITES: PLAYER FROM: AVATAR: " + fetchInvitesData[i].playerFrom.avatar);
Debug.Log("FETCH INVITES: PLAYER FROM: CREDITIALS: " + fetchInvitesData[i].playerFrom.credentials);
Debug.Log("FETCH INVITES: PLAYER FROM: ID: " + fetchInvitesData[i].playerFrom.id);
Debug.Log("FETCH INVITES: PLAYER FROM: NAME: " + fetchInvitesData[i].playerFrom.name);
Debug.Log("FETCH INVITES: PLAYER FROM: PLATFORM TYPE: " + fetchInvitesData[i].playerFrom.platformType);
Debug.Log("FETCH INVITES: PLAYER FROM: PROJECT ID: " + fetchInvitesData[i].playerFrom.projectId);
Debug.Log("FETCH INVITES: PLAYER FROM: SCORE: " + fetchInvitesData[i].playerFrom.score);
}
}
Execution with error:
- JavaScript
- Unity
ss.channels.on('error:fetchInvites', (err) => {
// completed with an error
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnFetchInvitesError += OnFetchInvitesError;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnFetchInvitesError -= OnFetchInvitesError;
}
private void OnFetchInvitesError() => Debug.Log("FETCH INVITES: ERROR");
Possible errors are shown in the table below:
Basic Errors |
---|
player_not_found |
project_not_found |
origin_not_allowed |
player_banned |
internal_error |
To load more invites for the same request, there is a convenient method:
- JavaScript
- Unity
const response = await ss.channels.fetchMoreInvites({
// how much to request at a time, max. 100
limit: 100
})
// limit - how much to request at a time, max. 100
SS_Channels.FetchMoreInvites(limit: 100);
To get the result of a method call, you can subscribe to events:
- JavaScript
- Unity
ss.channels.on('fetchMoreInvites', (result) => {
result.items // array of list of invites
result.canLoadMore // is it possible to load more invites
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnFetchMoreInvites += OnFetchMoreInvites;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnFetchMoreInvites -= OnFetchMoreInvites;
}
private void OnFetchMoreInvites(SS_Data data, bool canLoadMore)
{
var fetchInvitesData = data.GetList<FetchInvitesData>();
Debug.Log("FETCH MORE INVITES: INVITES COUNT: " + fetchInvitesData.Count);
Debug.Log("FETCH MORE INVITES: CAN LOAD MORE: " + canLoadMore);
}
Execution with error:
- JavaScript
- Unity
ss.channels.on('error:fetchMoreInvites', (err) => {
// completed with an error
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnFetchMoreInvitesError += OnFetchMoreInvitesError;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnFetchMoreInvitesError -= OnFetchMoreInvitesError;
}
private void OnFetchMoreInvitesError() => Debug.Log("FETCH MORE INVITES: ERROR");
Possible errors are shown in the table below:
Basic Errors |
---|
player_not_found |
project_not_found |
origin_not_allowed |
player_banned |
internal_error |
Get a List of Sent Invitations from a Channel​
+1Â RequestWith the ss.channels.fetchChannelInvites
method, you can get a list of all sent invitations in the selected channel:
- JavaScript
- Unity
const response = await ss.channels.fetchChannelInvites({
// Channel ID
channelId: 123,
// how much to request at a time, max. 100
limit: 100,
// how many entries to skip, max. 10000, used for page navigation or "load more"
offset: 0
})
// limit - how much to request at a time, max. 100
// offset - how many entries to skip, max. 10000, used for page navigation or "load more"
SS_Channels.FetchChannelInvites(channel_ID: 123, limit: 50, offset: 0);
Mandatory access rights Allow to invite other players
To get the result of a method call, you can subscribe to events:
- JavaScript
- Unity
ss.channels.on('fetchChannelInvites', (result) => {
result.items // array of list of invites
result.canLoadMore // is it possible to load more invites
result.items.forEach((invite) => {
// all fields of the invite
// Public fields of the player who invites
invite.playerFrom
invite.playerFrom.id
invite.playerFrom.name
invite.playerFrom.avatar
// and other public fields
// Public fields of the player who is invited
invite.playerTo
invite.playerTo.id
invite.playerTo.name
invite.playerTo.avatar
// and other public fields
// date the invitation was sent, ISO 8601
invite.date
})
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnFetchChannelInvites += OnFetchChannelInvites;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnFetchChannelInvites -= OnFetchChannelInvites;
}
private void OnFetchChannelInvites(SS_Data data, bool canLoadMore)
{
var fetchChannelInvites = data.GetList<FetchChannelInvitesData>();
Debug.Log("FETCH CHANNEL INVITES: CAN LOAD MORE: " + canLoadMore);
for (int i = 0; i < fetchChannelInvites.Count; i++)
{
Debug.Log("FETCH CHANNEL INVITES: DATE: " + fetchChannelInvites[i].date);
Debug.Log("FETCH CHANNEL INVITES: PLAYER FROM: AVATAR: " + fetchChannelInvites[i].playerFrom.avatar);
Debug.Log("FETCH CHANNEL INVITES: PLAYER FROM: CREDITIALS: " + fetchChannelInvites[i].playerFrom.credentials);
Debug.Log("FETCH CHANNEL INVITES: PLAYER FROM: ID: " + fetchChannelInvites[i].playerFrom.id);
Debug.Log("FETCH CHANNEL INVITES: PLAYER FROM: NAME: " + fetchChannelInvites[i].playerFrom.name);
Debug.Log("FETCH CHANNEL INVITES: PLAYER FROM: PLATFORM TYPE: " + fetchChannelInvites[i].playerFrom.platformType);
Debug.Log("FETCH CHANNEL INVITES: PLAYER FROM: PROJECT ID: " + fetchChannelInvites[i].playerFrom.projectId);
Debug.Log("FETCH CHANNEL INVITES: PLAYER FROM: SCORE: " + fetchChannelInvites[i].playerFrom.score);
Debug.Log("FETCH CHANNEL INVITES: PLAYER TO: AVATAR: " + fetchChannelInvites[i].playerTo.avatar);
Debug.Log("FETCH CHANNEL INVITES: PLAYER TO: CREDITIALS: " + fetchChannelInvites[i].playerTo.credentials);
Debug.Log("FETCH CHANNEL INVITES: PLAYER TO: ID: " + fetchChannelInvites[i].playerTo.id);
Debug.Log("FETCH CHANNEL INVITES: PLAYER TO: NAME: " + fetchChannelInvites[i].playerTo.name);
Debug.Log("FETCH CHANNEL INVITES: PLAYER TO: PLATFORM TYPE: " + fetchChannelInvites[i].playerTo.platformType);
Debug.Log("FETCH CHANNEL INVITES: PLAYER TO: PROJECT ID: " + fetchChannelInvites[i].playerTo.projectId);
Debug.Log("FETCH CHANNEL INVITES: PLAYER TO: SCORE: " + fetchChannelInvites[i].playerTo.score);
}
}
Execution with error:
- JavaScript
- Unity
ss.channels.on('error:fetchChannelInvites', (err) => {
// completed with an error
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnFetchChannelInvitesError += OnFetchChannelInvitesError;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnFetchChannelInvitesError -= OnFetchChannelInvitesError;
}
private void OnFetchChannelInvitesError() => Debug.Log("FETCH CHANNEL INVITES: ERROR");
Possible errors are shown in the table below:
Basic Errors | Script Errors |
---|---|
player_not_found | empty_channel_id |
project_not_found | channel_not_found |
origin_not_allowed | access_denied |
player_banned | |
internal_error |
To load more invites for the same request, there is a convenient method:
- JavaScript
- Unity
const response = await ss.channels.fetchMoreChannelInvites({
channelId: 123,
// how much to request at a time, max. 100
limit: 100
})
// limit - how much to request at a time, max. 100
SS_Channels.FetchMoreChannelInvites(channel_ID: 123, limit: 100);
To get the result of a method call, you can subscribe to events:
- JavaScript
- Unity
ss.channels.on('fetchMoreChannelInvites', (result) => {
result.items // array of list of invites
result.canLoadMore // is it possible to load more invites
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnFetchMoreChannelInvites += OnFetchMoreChannelInvites;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnFetchMoreChannelInvites -= OnFetchMoreChannelInvites;
}
private void OnFetchMoreChannelInvites(SS_Data data, bool canLoadMore)
{
var fetchChannelInvites = data.GetList<FetchChannelInvitesData>();
Debug.Log("FETCH MORE CHANNEL INVITES: CHANNEK INVITES COUNT: " + fetchChannelInvites.Counte);
Debug.Log("FETCH MORE CHANNEL INVITES: CAN LOAD MORE: " + canLoadMore);
}
Execution with error:
- JavaScript
- Unity
ss.channels.on('error:fetchMoreChannelInvites', (err) => {
// completed with an error
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnFetchMoreChannelInvitesError += OnFetchMoreChannelInvitesError;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnFetchMoreChannelInvitesError -= OnFetchMoreChannelInvitesError;
}
private void OnFetchMoreChannelInvitesError() => Debug.Log("FETCH MORE CHANNEL INVITES: ERROR");
Possible errors are shown in the table below:
Basic Errors | Script Errors |
---|---|
player_not_found | empty_channel_id |
project_not_found | channel_not_found |
origin_not_allowed | access_denied |
player_banned | |
internal_error |
Get a List of Sent Invitations to Players in Channels​
+1Â RequestYou can get a list of invitations sent to players in channels using the method ss.channels.fetchSentInvites
:
- JavaScript
- Unity
const response = await ss.channels.fetchSentInvites({
// how much to request at a time, max. 100
limit: 100,
// how many entries to skip, max. 10000, used for page navigation or "load more"
offset: 0
})
// limit - how much to request at a time, max. 100
// offset - how many entries to skip, max. 10000, used for page navigation or "load more"
SS_Channels.FetchSentInvites(channelId: 123, limit: 100, offset: 0);
To get the result of a method call, you can subscribe to events:
- JavaScript
- Unity
ss.channels.on('fetchSentInvites', (result) => {
result.items // array of list of invites
result.canLoadMore // is it possible to load more invites
result.items.forEach((invite) => {
// all fields of the invite
// fields of the channel to which the other player is invited
invite.channel
invite.channel.id
invite.channel.tags
invite.channel.projectId
invite.channel.capacity
invite.channel.ownerId
invite.channel.name
invite.channel.description
invite.channel.private
invite.channel.visible
invite.channel.hasPassword
invite.channel.membersCount
// Public fields of the player who is invited
invite.playerTo
invite.playerTo.id
invite.playerTo.name
invite.playerTo.avatar
// and other public fields
// date the invitation was sent, ISO 8601
invite.date
})
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnFetchSentInvites += OnFetchSentInvites;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnFetchSentInvites -= OnFetchSentInvites;
}
private void OnFetchSentInvites(SS_Data data, bool canLoadMore)
{
var fetchSentInvites = data.GetList<FetchSentInvitesData>();
Debug.Log("FETCH SENT INVITES: CAN LOAD MORE: " + canLoadMore);
for (int i = 0; i < fetchSentInvites.Count; i++)
{
Debug.Log("FETCH SENT INVITES: DATE: " + fetchSentInvites[i].date);
Debug.Log("FETCH SENT INVITES: CHANNEL: ID: " + fetchSentInvites[i].channel.id);
for (int x = 0; x < fetchSentInvites[i].channel.tags.Length; x++)
{
Debug.Log("FETCH SENT INVITES: CHANNEL: TAGS: " + fetchSentInvites[i].channel.tags[x]);
}
for (int a = 0; a < fetchSentInvites[i].channel.messageTags.Length; a++)
{
Debug.Log("FETCH SENT INVITES: CHANNEL: MESSAGE TAGS: " + fetchSentInvites[i].channel.messageTags[a]);
}
Debug.Log("FETCH SENT INVITES: CHANNEL: TEMPLATE ID: " + fetchSentInvites[i].channel.templateId);
Debug.Log("FETCH SENT INVITES: CHANNEL: PROJECT ID: " + fetchSentInvites[i].channel.projectId);
Debug.Log("FETCH SENT INVITES: CHANNEL: CAPACITY: " + fetchSentInvites[i].channel.capacity);
Debug.Log("FETCH SENT INVITES: CHANNEL: OWNER ID: " + fetchSentInvites[i].channel.ownerId);
Debug.Log("FETCH SENT INVITES: CHANNEL: NAME: " + fetchSentInvites[i].channel.name);
Debug.Log("FETCH SENT INVITES: CHANNEL: DESCRIPTION: " + fetchSentInvites[i].channel.description);
Debug.Log("FETCH SENT INVITES: CHANNEL: PRIVATE: " + fetchSentInvites[i].channel.ch_private);
Debug.Log("FETCH SENT INVITES: CHANNEL: VISIBLE: " + fetchSentInvites[i].channel.visible);
Debug.Log("FETCH SENT INVITES: CHANNEL: PERMANENT: " + fetchSentInvites[i].channel.permanent);
Debug.Log("FETCH SENT INVITES: CHANNEL: HAS PASSWORD: " + fetchSentInvites[i].channel.hasPassword);
Debug.Log("FETCH SENT INVITES: CHANNEL: PASSWORD: " + fetchSentInvites[i].channel.password);
Debug.Log("FETCH SENT INVITES: CHANNEL: IS JOINED: " + fetchSentInvites[i].channel.isJoined);
Debug.Log("FETCH SENT INVITES: CHANNEL: IS INVITED: " + fetchSentInvites[i].channel.isInvited);
Debug.Log("FETCH SENT INVITES: CHANNEL: IS MUTED: " + fetchSentInvites[i].channel.isMuted);
Debug.Log("FETCH SENT INVITES: CHANNEL: IS REQUEST SENT: " + fetchSentInvites[i].channel.isRequestSent);
Debug.Log("FETCH SENT INVITES: CHANNEL: MEMBERS COUNT: " + fetchSentInvites[i].channel.membersCount);
Debug.Log("FETCH SENT INVITES: CHANNEL: OWNER ACL: " + JsonUtility.ToJson(fetchSentInvites[i].channel.ownerAcl));
Debug.Log("FETCH SENT INVITES: CHANNEL: MEMBER ACL: " + JsonUtility.ToJson(fetchSentInvites[i].channel.memberAcl));
Debug.Log("FETCH SENT INVITES: CHANNEL: GUEST ACL: " + JsonUtility.ToJson(fetchSentInvites[i].channel.guestAcl));
Debug.Log("FETCH SENT INVITES: PLAYER TO: AVATAR: " + fetchSentInvites[i].playerTo.avatar);
Debug.Log("FETCH SENT INVITES: PLAYER TO: CREDITIALS: " + fetchSentInvites[i].playerTo.credentials);
Debug.Log("FETCH SENT INVITES: PLAYER TO: ID: " + fetchSentInvites[i].playerTo.id);
Debug.Log("FETCH SENT INVITES: PLAYER TO: NAME: " + fetchSentInvites[i].playerTo.name);
Debug.Log("FETCH SENT INVITES: PLAYER TO: PLATFORM TYPE: " + fetchSentInvites[i].playerTo.platformType);
Debug.Log("FETCH SENT INVITES: PLAYER TO: PROJECT ID: " + fetchSentInvites[i].playerTo.projectId);
Debug.Log("FETCH SENT INVITES: PLAYER TO: SCORE: " + fetchSentInvites[i].playerTo.score);
}
}
Execution with error:
- JavaScript
- Unity
ss.channels.on('error:fetchSentInvites', (err) => {
// completed with an error
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnFetchSentInvitesError += OnFetchSentInvitesError;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnFetchSentInvitesError -= OnFetchSentInvitesError;
}
// completed with an error
private void OnFetchSentInvitesError() => ConsoleUI.Instance.Log("FETCH SENT INVITES: ERROR");
Possible errors are shown in the table below:
Basic Errors |
---|
player_not_found |
project_not_found |
origin_not_allowed |
player_banned |
internal_error |
To additionally load invites for the same request, use a convenient method ss.channels.fetchMoreSentInvites
:
- JavaScript
- Unity
const response = await ss.channels.fetchMoreSentInvites({
// how much to request at a time, max. 100
limit: 100
})
SS_Channels.FetchMoreSentInvites(channelId: 123, limit: 100);
To get the result of a method call, you can subscribe to events:
- JavaScript
- Unity
ss.channels.on('fetchMoreSentInvites', (result) => {
result.items // array of list of invites
result.canLoadMore // is it possible to load more invites
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnFetchMoreSentInvites += OnFetchMoreSentInvites;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnFetchMoreSentInvites -= OnFetchMoreSentInvites;
}
private void OnFetchMoreSentInvites(SS_Data data, bool canLoadMore)
{
var fetchSentInvites = data.GetList<FetchSentInvitesData>();
Debug.Log("FETCH MORE SENT INVITES: CAN LOAD MORE: " + canLoadMore);
for (int i = 0; i < fetchSentInvites.Count; i++)
{
Debug.Log("FETCH MORE SENT INVITES: DATE: " + fetchSentInvites[i].date);
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: ID: " + fetchSentInvites[i].channel.id);
for (int x = 0; x < fetchSentInvites[i].channel.tags.Length; x++)
{
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: TAGS: " + fetchSentInvites[i].channel.tags[x]);
}
for (int a = 0; a < fetchSentInvites[i].channel.messageTags.Length; a++)
{
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: MESSAGE TAGS: " + fetchSentInvites[i].channel.messageTags[a]);
}
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: TEMPLATE ID: " + fetchSentInvites[i].channel.templateId);
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: PROJECT ID: " + fetchSentInvites[i].channel.projectId);
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: CAPACITY: " + fetchSentInvites[i].channel.capacity);
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: OWNER ID: " + fetchSentInvites[i].channel.ownerId);
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: NAME: " + fetchSentInvites[i].channel.name);
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: DESCRIPTION: " + fetchSentInvites[i].channel.description);
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: PRIVATE: " + fetchSentInvites[i].channel.ch_private);
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: VISIBLE: " + fetchSentInvites[i].channel.visible);
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: PERMANENT: " + fetchSentInvites[i].channel.permanent);
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: HAS PASSWORD: " + fetchSentInvites[i].channel.hasPassword);
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: PASSWORD: " + fetchSentInvites[i].channel.password);
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: IS JOINED: " + fetchSentInvites[i].channel.isJoined);
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: IS INVITED: " + fetchSentInvites[i].channel.isInvited);
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: IS MUTED: " + fetchSentInvites[i].channel.isMuted);
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: IS REQUEST SENT: " + fetchSentInvites[i].channel.isRequestSent);
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: MEMBERS COUNT: " + fetchSentInvites[i].channel.membersCount);
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: OWNER ACL: " + JsonUtility.ToJson(fetchSentInvites[i].channel.ownerAcl));
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: MEMBER ACL: " + JsonUtility.ToJson(fetchSentInvites[i].channel.memberAcl));
Debug.Log("FETCH MORE SENT INVITES: CHANNEL: GUEST ACL: " + JsonUtility.ToJson(fetchSentInvites[i].channel.guestAcl));
Debug.Log("FETCH MORE SENT INVITES: PLAYER TO: AVATAR: " + fetchSentInvites[i].playerTo.avatar);
Debug.Log("FETCH MORE SENT INVITES: PLAYER TO: CREDITIALS: " + fetchSentInvites[i].playerTo.credentials);
Debug.Log("FETCH MORE SENT INVITES: PLAYER TO: ID: " + fetchSentInvites[i].playerTo.id);
Debug.Log("FETCH MORE SENT INVITES: PLAYER TO: NAME: " + fetchSentInvites[i].playerTo.name);
Debug.Log("FETCH MORE SENT INVITES: PLAYER TO: PLATFORM TYPE: " + fetchSentInvites[i].playerTo.platformType);
Debug.Log("FETCH MORE SENT INVITES: PLAYER TO: PROJECT ID: " + fetchSentInvites[i].playerTo.projectId);
Debug.Log("FETCH MORE SENT INVITES: PLAYER TO: SCORE: " + fetchSentInvites[i].playerTo.score);
}
}
Execution with error:
- JavaScript
- Unity
ss.channels.on('error:fetchMoreSentInvites', (err) => {
// completed with an error
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnFetchMoreSentInvitesError += OnFetchMoreSentInvitesError;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnFetchMoreSentInvitesError -= OnFetchMoreSentInvitesError;
}
private void OnFetchMoreSentInvitesError() => Debug.Log("FETCH MORE SENT INVITES: ERROR");
Possible errors are shown in the table below:
Basic Errors |
---|
player_not_found |
project_not_found |
origin_not_allowed |
player_banned |
internal_error |
Stay in Touch​
Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.
SpellSync Community Telegram
: @spellsync.
For your suggestions e-mail
: [email protected]
We Wish you Success!