Channel Management
Overview
Methods for managing channels are considered:
ss.channels.createChannel
- channel creation +1 Requestss.channels.updateChannel
- channel update +1 Requestss.channels.deleteChannel
- deleting a channel +1 Requestss.channels.fetchChannel
- get channel information by ID +1 Requestss.channels.fetchChannels
- get channel list by id +1 Requestss.channels.fetchMoreChannels
- additionally load the list of channels +1 Request
In real time, you can track any actions of other players in the channel: they wrote a message, joined or invited to the channel, etc.
Create a Channel
+1 RequestThe player can create channels only from templates preinstalled by the developer. When creating a channel, the player automatically joins it.
The ss.channels.createChannel
method is used to create a channel. As an example, we will show the creation of a channel - a group for passing the Demons Lord Castle
dungeon for 5 people x5
in the heroic difficulty heroic
.
Channel fields are editable if editable in template
- JavaScript
- Unity
ss.channels.createChannel({
// required ID or channel template tag
template: 'DUNGEON_5',
// optional tags by which you can find the channel
tags: ['dungeon', 'x5', 'demons_lord_castle', 'heroic'],
// maximum number of people in the channel
capacity: 5,
// channel name
name: 'Dungeon Demons Lord Castle',
// channel description
description: 'fast, need all',
// entrance by invitation only or free
private: true,
// the channel is visible in the search or is available only by direct request
visible: true,
// login password
password: '',
// channel owner access
ownerAcl: {
// can read messages
canViewMessages: true,
// can create messages
canAddMessage: true,
// can change messages
canEditMessage: true,
// can delete messages
canDeleteMessage: true,
// can view members
canViewMembers: true,
// can invite other players
canInvitePlayer: true,
// can remove players
canKickPlayer: true,
// can accept requests to join
canAcceptJoinRequest: true,
// can mute players
canMutePlayer: true
},
// channel member access
memberAcl: {
// can read messages
canViewMessages: true,
// can create messages
canAddMessage: true,
// can change messages
canEditMessage: true,
// can delete messages
canDeleteMessage: true,
// can view members
canViewMembers: true,
// can invite other players
canInvitePlayer: false,
// can remove players
canKickPlayer: false,
// can accept requests to join
canAcceptJoinRequest: false,
// can mute players
canMutePlayer: false
},
// channel guest access
guestAcl: {
// can read messages
canViewMessages: false,
// can create messages
canAddMessage: false,
// can change messages
canEditMessage: false,
// can delete messages
canDeleteMessage: false,
// can view members
canViewMembers: false,
// can invite other players
canInvitePlayer: false,
// can remove players
canKickPlayer: false,
// can accept requests to join
canAcceptJoinRequest: false,
// can mute players
canMutePlayer: false
}
})
public void Create()
{
// required ID of channel template
var filter = new CreateChannelFilter(5);
// optional tags by which you can find the channel
filter.tags = new string[] {"dungeon", "x5", "demons_lord_castle", "heroic"};
// maximum number of people in the channel
filter.capacity = 5;
// channel name
filter.name = 'Dungeon Demons Lord Castle',
// channel description
filter.description = 'fast, need all',
// entrance by invitation only or free
filter.private = true,
// the channel is visible in the search or is available only by direct request
filter.visible = true,
// login password
filter.password = '',
// channel owner access
var ownerAcl = new OwnerAcl();
// can read messages
ownerAcl.canViewMessages = true;
// can create messages
ownerAcl.canAddMessage = true;
// can change messages
ownerAcl.canEditMessage = true;
// can delete messages
ownerAcl.canDeleteMessage = true;
// can view members
ownerAcl.canViewMembers = true;
// can invite other players
ownerAcl.canInvitePlayer = true;
// can remove players
ownerAcl.canKickPlayer = true;
// can accept requests to join
ownerAcl.canAcceptJoinRequest = true;
// can mute players
ownerAcl.canMutePlayer = true;
filter.ownerAcl = ownerAcl;
// channel member access
var memberAcl = new MemberAcl();
// can read messages
memberAcl.canViewMessages = true;
// can create messages
memberAcl.canAddMessage = true;
// can change messages
memberAcl.canEditMessage = true;
// can delete messages
memberAcl.canDeleteMessage = true;
// can view members
memberAcl.canViewMembers = true;
// can invite other players
memberAcl.canInvitePlayer = false;
// can remove players
memberAcl.canKickPlayer = false;
// can accept requests to join
memberAcl.canAcceptJoinRequest = false;
// can mute players
memberAcl.canMutePlayer = false;
filter.memberAcl = memberAcl;
// channel guest access
var guestAcl = new GuestAcl();
// can read messages
guestAcl.canViewMessages = false;
// can create messages
guestAcl.canAddMessage = false;
// can change messages
guestAcl.canEditMessage = false;
// can delete messages
guestAcl.canDeleteMessage = false;
// can view members
guestAcl.canViewMembers = false;
// can invite other players
guestAcl.canInvitePlayer = false;
// can remove players
guestAcl.canKickPlayer = false;
// can accept requests to join
guestAcl.canAcceptJoinRequest = false;
// can mute players
guestAcl.canMutePlayer = false;
filter.guestAcl = guestAcl;
SS_Channels.CreateChannel(filter);
}
Install the password of the channel by passing the line with a password, for example, password: '123'
. You can remove the password by passing the empty line password: ''
.
All Fields of the Channel
To get the result of the call of the method ss.channels.createChannel
, you can subscribe to events:
- JavaScript
- Unity
ss.channels.on('createChannel', (channel) => {
// all fields of the channel
channel.id
channel.tags
channel.messageTags
channel.templateId
channel.capacity
channel.ownerId
channel.name
channel.description
channel.private
channel.visible
channel.permanent
channel.hasPassword
channel.isJoined
channel.isRequestSent
channel.isInvited
channel.isMuted
channel.password
channel.membersCount
channel.ownerAcl
channel.memberAcl
channel.guestAcl
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnCreateChannel += OnCreateChannel;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnCreateChannel -= OnCreateChannel;
}
private void OnCreateChannel(CreateChannelData data)
{
Debug.Log("ON CHANNEL CREATE: ID: " + data.id);
for (int x = 0; x < data.tags.Length; x++)
{
Debug.Log("ON CHANNEL CREATE: TAGS: " + data.tags[x]);
}
for (int i = 0; i < data.messageTags.Length; i++)
{
Debug.Log("ON CHANNEL CREATE: MESSAGE TAGS: " + data.messageTags[i]);
}
Debug.Log("ON CHANNEL CREATE: TEMPLATE ID: " + data.templateId);
Debug.Log("ON CHANNEL CREATE: CAPACITY: " + data.capacity);
Debug.Log("ON CHANNEL CREATE: OWNER ID: " + data.ownerId);
Debug.Log("ON CHANNEL CREATE: NAME: " + data.name);
Debug.Log("ON CHANNEL CREATE: DESCRIPTION: " + data.description);
Debug.Log("ON CHANNEL CREATE: PRIVATE: " + data.ch_private);
Debug.Log("ON CHANNEL CREATE: VISIBLE: " + data.visible);
Debug.Log("ON CHANNEL CREATE: PERMANENT: " + data.permanent);
Debug.Log("ON CHANNEL CREATE: HAS PASSWORD: " + data.hasPassword);
Debug.Log("ON CHANNEL CREATE: IS JOINED: " + data.isJoined);
Debug.Log("ON CHANNEL CREATE: IS REQUEST SENT: " + data.isRequestSent);
Debug.Log("ON CHANNEL CREATE: IS INVITED: " + data.isInvited);
Debug.Log("ON CHANNEL CREATE: IS MUTED: " + data.isMuted);
Debug.Log("ON CHANNEL CREATE: PASSWORD: " + data.password);
Debug.Log("ON CHANNEL CREATE: MEMBERS COUNT: " + data.membersCount);
Debug.Log("ON CHANNEL CREATE: OWNER ACL: " + JsonUtility.ToJson(data.ownerAcl));
Debug.Log("ON CHANNEL CREATE: MemberAcl: " + JsonUtility.ToJson(data.memberAcl));
Debug.Log("ON CHANNEL CREATE: Guest Acl: " + JsonUtility.ToJson(data.guestAcl));
}
Example of execution with an error:
- JavaScript
- Unity
ss.channels.on('error:createChannel', (err) => {
// Completed with an error
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnCreateChannelError += OnCreateChannelError;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnCreateChannelError -= OnCreOnCreateChannelErrorateChannel;
}
// Completed with an error
private void OnCreateChannelError() => Debug.Log("CREATE CHANNEL: ERROR");
Possible errors are given in the table below:
Basic Errors | Scenario Errors |
---|---|
player_not_found | empty_channel_template_id |
project_not_found | channel_template_not_found |
origin_not_allowed | channel_tag_forbidden 💡 |
player_banned | |
internal_error |
channel_tag_forbidden 💡 - channel tags contain reserved system tags. System tags begin with @, for example @feed: 123456
Create a Channel from the Control Panel
To create a channel from the SpellSync control panel, go to the Channels and press the Add channel button:
The names of the fields available for editing in the channel are given in the table below:
Field Name | Comments |
---|---|
📝 Channel Template | See more in section Template |
📝 Tags | Channel tags are used to simplify the search player in the in-game events.For example, a group for going to a dungeon for 5 people can have dungeon and x5 tags.See more in the section Tags of Channels and Messages |
📝 Tags of messages | Messages tags allow you to display logs or specified types of chat messages.For example, all messages with log tags can return information about the level of level. See more in the section Tags of Channels and Messages |
📝 Channel name | Clicking on the Edit translations button opens the entire list of languages available for translation |
📝 Channel description | Clicking on the Edit translations button opens the entire list of languages available for translation |
📝 The maximum number of members | Integer, maximum number of channel members is unlimited |
📝 Password | By default, the channel is created without a password |
🔘 Private | Allows you to join the channel only through Request or Invites |
🔘 Keep history | Allows you to store your message history (only available on subscription plans). By default, messages are stored for 24 hours |
🔘 Visible in search | Shows the channel in the search results |
🔘 Visible only in test version 💡 | The channel is not visible to players in the production version |
🔘 Leave the channel when he leaves the game | |
🔘 Delete channel when last member leaves | |
🔘 Permissions for the player - owner to edit channel options | By default, channel owner can edit: title, description, tags, change owner, channel capacity, privacy, visibility, owner ACL, guest ACL |
🔘 Owner, member, guest access | For a complete list of permissions and their default values, see table |
If you leave the default settings, then the created channel can be used as a player chat
Access of Roles in Channel
Method | Allow to | ownerAcl owner | memberAcl member | guestAcl guest |
---|---|---|---|---|
canViewMessages | read messages | true 🔘 | true 🔘 | false ⚪ |
canAddMessage | create messages | true 🔘 | true 🔘 | false ⚪ |
canEditMessage | change messages | true 🔘 | true 🔘 | false ⚪ |
canDeleteMessage | delete messages | true 🔘 | true 🔘 | false ⚪ |
canViewMembers | view participants | true 🔘 | true 🔘 | false ⚪ |
canInvitePlayer | invite other players | true 🔘 | false ⚪ | false ⚪ |
canKickPlayer | delete players | true 🔘 | false ⚪ | false ⚪ |
canAcceptJoinRequest | accept join requests | true 🔘 | false ⚪ | false ⚪ |
canMutePlayer | mute players | true 🔘 | false ⚪ | false ⚪ |
To manage the rights of players in the channel, select the control panels Channels - Change - Accesses of the player - owner / member / guest:
Channel Update
+1 RequestTo update the channel with the channelId: 123
using the method ss.channels.updateChannel
:
- JavaScript
- Unity
ss.channels.updateChannel({ channelId: 123, visible: false })
public void UpdateChannel()
{
var filter = new UpdateChannelFilter(Channel_ID: 123);
filter.capacity = 50;
filter.visible = false;
filter.ch_private = true;
SS_Channels.UpdateChannel(filter);
}
Transfer the channel to another player:
- JavaScript
- Unity
ss.channels.updateChannel({ channelId: 123, ownerId: 123456 })
public void UpdateChannel()
{
var filter = new UpdateChannelFilter(Channel_ID: 123);
filter.ownerId = 123456;
SS_Channels.UpdateChannel(filter);
}
Full list of options:
- JavaScript
- Unity
ss.channels.updateChannel({
// required channel ID to update
channelId: 123,
// tags by which you can find the channel
tags: ['dungeon', 'x5', 'demons_lord_castle', 'heroic'],
// maximum number of people in the channel
capacity: 5,
// channel name
name: 'Dungeon Demons Lord Castle',
// channel description
description: 'fast, need all',
// entrance by invitation only or free
private: true,
// the channel is visible in the search or is available only by direct request
visible: true,
// login password
password: '',
// new owner ID
ownerId: 123456,
// channel owner access
ownerAcl: {
// can read messages
canViewMessages: true,
// can create messages
canAddMessage: true,
// can change messages
canEditMessage: true,
// can delete messages
canDeleteMessage: true,
// can view members
canViewMembers: true,
// can invite other players
canInvitePlayer: true,
// can remove players
canKickPlayer: true,
// can accept requests to join
canAcceptJoinRequest: true,
// can mute players
canMutePlayer: true
},
// channel member access
memberAcl: {
// can read messages
canViewMessages: true,
// can create messages
canAddMessage: true,
// can change messages
canEditMessage: true,
// can delete messages
canDeleteMessage: true,
// can view members
canViewMembers: true,
// can invite other players
canInvitePlayer: false,
// can remove players
canKickPlayer: false,
// can accept requests to join
canAcceptJoinRequest: false,
// can mute players
canMutePlayer: false
},
// channel guest access
guestAcl: {
// can read messages
canViewMessages: false,
// can create messages
canAddMessage: false,
// can change messages
canEditMessage: false,
// can delete messages
canDeleteMessage: false,
// can view members
canViewMembers: false,
// can invite other players
canInvitePlayer: false,
// can remove players
canKickPlayer: false,
// can accept requests to join
canAcceptJoinRequest: false,
// can mute players
canMutePlayer: false
}
})
public void UpdateChannel()
{
var filter = new UpdateChannelFilter(Channel_ID: 123);
// optional tags by which you can find the channel
filter.tags = new string[] {"dungeon", "x5", "demons_lord_castle", "heroic"};
// maximum number of people in the channel
filter.capacity = 5;
// channel name
filter.name = 'Dungeon Demons Lord Castle',
// channel description
filter.description = 'fast, need all',
// entrance by invitation only or free
filter.private = true,
// the channel is visible in the search or is available only by direct request
filter.visible = true,
// login password
filter.password = '',
// new owner ID
filter.ownerId = 123456;
// channel owner access
var ownerAcl = new OwnerAcl();
// can read messages
ownerAcl.canViewMessages = true;
// can create messages
ownerAcl.canAddMessage = true;
// can change messages
ownerAcl.canEditMessage = true;
// can delete messages
ownerAcl.canDeleteMessage = true;
// can view members
ownerAcl.canViewMembers = true;
// can invite other players
ownerAcl.canInvitePlayer = true;
// can remove players
ownerAcl.canKickPlayer = true;
// can accept requests to join
ownerAcl.canAcceptJoinRequest = true;
// can mute players
ownerAcl.canMutePlayer = true;
filter.ownerAcl = ownerAcl;
// channel member access
var memberAcl = new MemberAcl();
// can read messages
memberAcl.canViewMessages = true;
// can create messages
memberAcl.canAddMessage = true;
// can change messages
memberAcl.canEditMessage = true;
// can delete messages
memberAcl.canDeleteMessage = true;
// can view members
memberAcl.canViewMembers = true;
// can invite other players
memberAcl.canInvitePlayer = false;
// can remove players
memberAcl.canKickPlayer = false;
// can accept requests to join
memberAcl.canAcceptJoinRequest = false;
// can mute players
memberAcl.canMutePlayer = false;
filter.memberAcl = memberAcl;
// channel guest access
var guestAcl = new GuestAcl();
// can read messages
guestAcl.canViewMessages = false;
// can create messages
guestAcl.canAddMessage = false;
// can change messages
guestAcl.canEditMessage = false;
// can delete messages
guestAcl.canDeleteMessage = false;
// can view members
guestAcl.canViewMembers = false;
// can invite other players
guestAcl.canInvitePlayer = false;
// can remove players
guestAcl.canKickPlayer = false;
// can accept requests to join
guestAcl.canAcceptJoinRequest = false;
// can mute players
guestAcl.canMutePlayer = false;
filter.guestAcl = guestAcl;
SS_Channels.UpdateChannel(filter);
}
To get the result of the method call, you can subscribe to events:
- JavaScript
- Unity
ss.channels.on('updateChannel', (channel) => {
// all fields of the channel
channel.id
channel.tags
channel.messageTags
channel.channelId
channel.capacity
channel.ownerId
channel.name
channel.description
channel.private
channel.visible
channel.permanent
channel.hasPassword
channel.isJoined
channel.isRequestSent
channel.isInvited
channel.isMuted
channel.password
channel.membersCount
channel.ownerAcl
channel.memberAcl
channel.guestAcl
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnUpdateChannel += OnUpdateChannel;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnUpdateChannel -= OnUpdateChannel;
}
private void OnUpdateChannel(UpdateChannelData data)
{
Debug.Log("UPDATE CHANNEL: ID: " + data.id);
for (int i = 0; i < data.tags.Length; i++)
{
Debug.Log("UPDATE CHANNEL: TAGS: " + data.tags[i]);
}
for (int i = 0; i < data.messageTags.Length; i++)
{
Debug.Log("UPDATE CHANNEL: MESSAGE TAGS: " + data.messageTags[i]);
}
Debug.Log("UPDATE CHANNEL: CAPACITY: " + data.capacity);
Debug.Log("UPDATE CHANNEL: OWNER ID: " + data.ownerId);
Debug.Log("UPDATE CHANNEL: NAME: " + data.name);
Debug.Log("UPDATE CHANNEL: DESCRIPTION: " + data.description);
Debug.Log("UPDATE CHANNEL: PRIVATE: " + data.ch_private);
Debug.Log("UPDATE CHANNEL: VISIBLE: " + data.visible);
Debug.Log("UPDATE CHANNEL: PERMANENT: " + data.permanent);
Debug.Log("UPDATE CHANNEL: HAS PASSWORD: " + data.hasPassword);
Debug.Log("UPDATE CHANNEL: PASSWORD: " + data.password);
Debug.Log("UPDATE CHANNEL: IS JOINED: " + data.isJoined);
Debug.Log("UPDATE CHANNEL: IS INVITED: " + data.isInvited);
Debug.Log("UPDATE CHANNEL: IS MUTED: " + data.isMuted);
Debug.Log("UPDATE CHANNEL: IS REQUEST SENT: " + data.isRequestSent);
Debug.Log("UPDATE CHANNEL: MEMBERS COUNT: " + data.membersCount);
Debug.Log("UPDATE CHANNEL: OWNER ACL: " + JsonUtility.ToJson(data.ownerAcl));
Debug.Log("UPDATE CHANNEL: MEMBER ACL: " + JsonUtility.ToJson(data.memberAcl));
Debug.Log("UPDATE CHANNEL: GUEST ACL: " + JsonUtility.ToJson(data.guestAcl));
}
Execution with an error:
- JavaScript
- Unity
ss.channels.on('error:updateChannel', (err) => {
// Completed with an error
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnUpdateChannelError += OnUpdateChannelError;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnUpdateChannelError -= OnUpdateChannelError;
}
// Completed with an error
private void OnUpdateChannelError() => Debug.Log("UPDATE CHANNEL: ERROR");
Possible errors are given in the table below:
Basic Errors | Scenario Errors |
---|---|
player_not_found | empty_channel_id |
project_not_found | channel_not_found |
origin_not_allowed | access_denied 💡 |
player_banned | channel_tag_forbidden 💡 |
internal_error |
access_denied 💡 - the player is not the owner, so he has no editing rights.
channel_tag_forbidden 💡 - Channel tags contain reserved system tags. System tags begin with @, for example @feed:123456
When updating the channel , all players in the channel come a notification of its change:
- JavaScript
- Unity
ss.channels.on('event:updateChannel', (channel) => {
// Channel ID
channel.id
// Channel tags
channel.tags
// Channel tags
channel.messageTags
// The maximum number of participants
channel.capacity
// The owner of the channel
channel.ownerId
// Channel name
channel.name
// Channel description
channel.description
// Channel privacy
channel.private
// Visibility of the channel
channel.visible
// The channel has a password
channel.hasPassword
// Access of the owner of the channel
channel.ownerAcl
// Access of the channel member
channel.memberAcl
// Access of the guest of the channel
channel.guestAcl
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnUpdateChannel += OnUpdateChannel;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnUpdateChannel -= OnUpdateChannel;
}
private void OnUpdateChannel(UpdateChannelData data)
{
Debug.Log("UPDATE CHANNEL: ID: " + data.id);
for (int i = 0; i < data.tags.Length; i++)
{
Debug.Log("UPDATE CHANNEL: TAGS: " + data.tags[i]);
}
for (int i = 0; i < data.messageTags.Length; i++)
{
Debug.Log("UPDATE CHANNEL: MESSAGE TAGS: " + data.messageTags[i]);
}
Debug.Log("UPDATE CHANNEL: CAPACITY: " + data.capacity);
Debug.Log("UPDATE CHANNEL: OWNER ID: " + data.ownerId);
Debug.Log("UPDATE CHANNEL: NAME: " + data.name);
Debug.Log("UPDATE CHANNEL: DESCRIPTION: " + data.description);
Debug.Log("UPDATE CHANNEL: PRIVATE: " + data.ch_private);
Debug.Log("UPDATE CHANNEL: VISIBLE: " + data.visible);
Debug.Log("UPDATE CHANNEL: PERMANENT: " + data.permanent);
Debug.Log("UPDATE CHANNEL: HAS PASSWORD: " + data.hasPassword);
Debug.Log("UPDATE CHANNEL: PASSWORD: " + data.password);
Debug.Log("UPDATE CHANNEL: IS JOINED: " + data.isJoined);
Debug.Log("UPDATE CHANNEL: IS INVITED: " + data.isInvited);
Debug.Log("UPDATE CHANNEL: IS MUTED: " + data.isMuted);
Debug.Log("UPDATE CHANNEL: IS REQUEST SENT: " + data.isRequestSent);
Debug.Log("UPDATE CHANNEL: MEMBERS COUNT: " + data.membersCount);
Debug.Log("UPDATE CHANNEL: OWNER ACL: " + JsonUtility.ToJson(data.ownerAcl));
Debug.Log("UPDATE CHANNEL: MEMBER ACL: " + JsonUtility.ToJson(data.memberAcl));
Debug.Log("UPDATE CHANNEL: GUEST ACL: " + JsonUtility.ToJson(data.guestAcl));
}
Delete the Channel
+1 RequestWhen removing the channel, the same ones are deleted: all messages, channel participants, invites and requests for joining the channel
To delete the channel with the identifier ChannelId: 123
, use the method ss.channels.deleteChannel
:
- JavaScript
- Unity
ss.channels.deleteChannel({ channelId: 123 })
SS_Channels.DeleteChannel(channel_ID: 123);
To get the result of the method call, you can subscribe to events:
- JavaScript
- Unity
ss.channels.on('deleteChannel', () => {
// The channel is deleted
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnDeleteChannelSuccess += OnDeleteChannelSuccess;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnDeleteChannelSuccess -= OnDeleteChannelSuccess;
}
// The channel is deleted
private void OnDeleteChannelSuccess() => Debug.Log("DELETE CHANNEL: SUCCESS");
Execution with an error:
- JavaScript
- Unity
ss.channels.on('error:deleteChannel', (err) => {
// Completed with an error
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnDeleteChannelError += OnDeleteChannelError;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnDeleteChannelError -= OnDeleteChannelError;
}
// Completed with an error
private void OnDeleteChannelError() => Debug.Log("DELETE CHANNEL: ERROR");
Possible errors are given in the table below:
Basic Errors | Scenario Errors |
---|---|
player_not_found | empty_channel_id |
project_not_found | channel_not_found |
origin_not_allowed | access_denied 💡 |
player_banned | |
internal_error |
access_denied 💡 - the player is not the owner, so he has no rights to remove the channel
When removing the channel, all players in the channel come a notification about this event:
- JavaScript
- Unity
ss.channels.on('event:deleteChannel', (channel) => {
// Channel ID
channel.id
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnDeleteChannelEvent += OnDeleteChannelEvent;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnDeleteChannelEvent -= OnDeleteChannelEvent;
}
private void OnDeleteChannelEvent(int channel_Id) => Debug.Log("DELETE CHANNEL EVENT: CHANNEL ID: " + channel_Id);
Get Channel Information by ID
+1 RequestTo get information about a channel by ID, use the method ss.channels.fetchChannel
:
- JavaScript
- Unity
const response = await ss.channels.fetchChannel({
// Channel ID
channelId: 123
})
SS_Channels.FetchChannel(channel_ID: 123);
To get the result of the method call, you can subscribe to events:
- JavaScript
- Unity
ss.channels.on('fetchChannel', (result) => {
// Channel fields
channel.id
channel.tags
channel.templateId
channel.capacity
channel.ownerId
channel.name
channel.description
channel.private
channel.visible
channel.hasPassword
channel.membersCount
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnFetchChannel += OnFetchChannel;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnFetchChannel -= OnFetchChannel;
}
private void OnFetchChannel(FetchChannelData data)
{
Debug.Log("FETCH CHANNEL: ID: " + data.id);
for (int i = 0; i < data.tags.Length; i++)
{
Debug.Log("FETCH CHANNEL: TAGS: " + data.tags[i]);
}
for (int i = 0; i < data.messageTags.Length; i++)
{
Debug.Log("FETCH CHANNEL: MESSAGE TAGS: " + data.messageTags[i]);
}
Debug.Log("FETCH CHANNEL: TEMPLATE ID: " + data.templateId);
Debug.Log("FETCH CHANNEL: PROJECT ID: " + data.projectId);
Debug.Log("FETCH CHANNEL: CAPACITY: " + data.capacity);
Debug.Log("FETCH CHANNEL: OWNER ID: " + data.ownerId);
Debug.Log("FETCH CHANNEL: NAME: " + data.name);
Debug.Log("FETCH CHANNEL: DESCRIPTION: " + data.description);
Debug.Log("FETCH CHANNEL: PRIVATE: " + data.ch_private);
Debug.Log("FETCH CHANNEL: VISIBLE: " + data.visible);
Debug.Log("FETCH CHANNEL: PERMANENT: " + data.permanent);
Debug.Log("FETCH CHANNEL: HAS PASSWORD: " + data.hasPassword);
Debug.Log("FETCH CHANNEL: PASSWORD: " + data.password);
Debug.Log("FETCH CHANNEL: IS JOINED: " + data.isJoined);
Debug.Log("FETCH CHANNEL: IS INVITED: " + data.isInvited);
Debug.Log("FETCH CHANNEL: IS MUTED: " + data.isMuted);
Debug.Log("FETCH CHANNEL: IS REQUEST SENT: " + data.isRequestSent);
Debug.Log("FETCH CHANNEL: MEMBERS COUNT: " + data.membersCount);
Debug.Log("FETCH CHANNEL: OWNER ACL: " + JsonUtility.ToJson(data.ownerAcl));
Debug.Log("FETCH CHANNEL: MEMBER ACL: " + JsonUtility.ToJson(data.memberAcl));
Debug.Log("FETCH CHANNEL: GUEST ACL: " + JsonUtility.ToJson(data.guestAcl));
}
Execution with an error:
- JavaScript
- Unity
ss.channels.on('error:fetchChannel', (err) => {
// Completed with an error
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnFetchChannelError += OnFetchChannelError;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnFetchChannelError -= OnFetchChannelError;
}
// Completed with an error
private void OnFetchChannelError() => Debug.Log("FETCH CHANNEL: ERROR");
Possible errors are given in the table below:
Basic Errors | Scenario Errors |
---|---|
player_not_found | empty_channel_id |
project_not_found | channel_not_found |
origin_not_allowed | |
player_banned | |
internal_error |
Fetch List of Channel
+1 RequestTo get a list of channels, you can use the method ss.channels.fetchChannels
:
- JavaScript
- Unity
const response = await ss.channels.fetchChannels({
// List of channel identifiers
ids: [123, 124, 125],
// Tags of channels for filtering, through (&)
tags: ['chat', 'trade'],
// Search by ID or channel name
search: '',
// Search for channels only in which there is my player
onlyJoined: true,
// Search for channels only in which my player is the owner of the channel
onlyOwned: true,
// How much to request at a time, Max.100
limit: 100,
// How many records can be missed, Max.10,000, used for page navigation or "load more"
offset: 0
})
public void FetchChannels()
{
var filter = new FetchChannelsFilter();
// List of channel identifiers
filter.ids = new int[] {123, 124, 125};
// Tags of channels for filtering, through (&)
filter.tags = new string[] {"chat", "trade"};
// Search by ID or channel name
filter.search = "";
// Search for channels only in which there is my player
filter.onlyJoined = true;
// Search for channels only in which my player is the owner of the channel
filter.onlyOwned = true;
// How much to request at a time, Max.100
filter.limit = 100;
// How many records can be missed, Max.10,000, used for page navigation or "load more"
filter.offset = 0;
SS_Channels.FetchChannels(filter);
}
To get the result of the method call, you can subscribe to events:
- JavaScript
- Unity
ss.channels.on('fetchChannels', (result) => {
result.items // An array of the list of channels
result.canLoadMore // Is it possible to load more channels
result.items.forEach((channel) => {
// Channel fields
channel.id
channel.tags
channel.templateId
channel.capacity
channel.ownerId
channel.name
channel.description
channel.private
channel.visible
channel.hasPassword
channel.membersCount
})
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnFetchChannels += OnFetchChannels;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnFetchChannels -= OnFetchChannels;
}
private void OnFetchChannels(List<FetchChannelData> data, bool canLoadMore)
{
Debug.Log("FETCH CHANNELS: CAN LOAD MORE: " + canLoadMore);
for (int i = 0; i < data.Count; i++)
{
Debug.Log("FETCH CHANNELS: ID: " + data[i].id);
Debug.Log("FETCH CHANNELS: NAME: " + data[i].name);
Debug.Log("FETCH CHANNELS: DESCRIPTION: " + data[i].description);
Debug.Log("FETCH CHANNELS: HAS PASSWORD: " + data[i].hasPassword);
Debug.Log("FETCH CHANNELS: MEMBERS COUNT: " + data[i].membersCount);
Debug.Log("FETCH CHANNELS: OWNER ID: " + data[i].ownerId);
Debug.Log("FETCH CHANNELS: PROJECT ID: " + data[i].projectId);
for (int x = 0; x < data[i].tags.Length; x++)
{
Debug.Log("FETCH CHANNELS: TAGS: " + data[i].tags[x]);
}
for (int a = 0; a < data[i].messageTags.Length; a++)
{
Debug.Log("FETCH CHANNELS: MESSAGE TAGS: " + data[i].messageTags[a]);
}
Debug.Log("FETCH CHANNELS: TEMPLATE ID: " + data[i].templateId);
Debug.Log("FETCH CHANNELS: CAPACITY: " + data[i].capacity);
Debug.Log("FETCH CHANNELS: VISIBLE: " + data[i].visible);
Debug.Log("FETCH CHANNELS: PRIVATE: " + data[i].ch_private);
Debug.Log("FETCH CHANNELS: PERMANENT: " + data[i].permanent);
Debug.Log("FETCH CHANNELS: HAS PASSWORD: " + data[i].hasPassword);
Debug.Log("FETCH CHANNELS: PASSWORD: " + data[i].password);
Debug.Log("FETCH CHANNELS: IS JOINED: " + data[i].isJoined);
Debug.Log("FETCH CHANNELS: IS INVITED: " + data[i].isInvited);
Debug.Log("FETCH CHANNELS: IS MUTED: " + data[i].isMuted);
Debug.Log("FETCH CHANNELS: IS REQUEST SENT: " + data[i].isRequestSent);
Debug.Log("FETCH CHANNELS: MEMBERS COUNT: " + data[i].membersCount);
Debug.Log("FETCH CHANNELS: OWNER ACL: " + JsonUtility.ToJson(data[i].ownerAcl));
Debug.Log("FETCH CHANNELS: MEMBER ACL: " + JsonUtility.ToJson(data[i].memberAcl));
Debug.Log("FETCH CHANNELS: GUEST ACL: " + JsonUtility.ToJson(data[i].guestAcl));
}
}
Execution with an error:
- JavaScript
- Unity
ss.channels.on('error:fetchChannels', (err) => {
// Completed with an error
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnFetchChannelsError += OnFetchChannelsError;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnFetchChannelsError -= OnFetchChannelsError;
}
// Completed with an error
private void OnFetchChannelsError() => Debug.Log("FETCH CHANNELS: ERROR");
Possible errors are given in the table below:
Basic Errors |
---|
player_not_found |
project_not_found |
origin_not_allowed |
player_banned |
internal_error |
To additionally load list of channels by the same request, there is a convenient method ss.channels.fetchMoreChannels
:
- JavaScript
- Unity
const response = await ss.channels.fetchMoreChannels({
// Channel ID
channelId: 123,
// Tags of messages for filtering, through (&)
tags: ['chat', 'trade'],
// How much to request at a time, Max.100
limit: 100
})
public void FetchMoreChannels()
{
var filter = new FetchMoreChannelsFilter();
// List of channel identifiers
filter.ids = new int[] {123, 124, 125};
// Tags of channels for filtering, through (&)
filter.tags = new string[] {"chat", "trade"};
// How much to request at a time, Max.100
filter.limit = 10;
SS_Channels.FetchMoreChannels(filter);
}
To get the result of the method call, you can subscribe to events:
- JavaScript
- Unity
ss.channels.on('fetchMoreChannels', (result) => {
result.items // An array of the list of channels
result.canLoadMore // Is it possible to load more channels
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnFetchMoreChannels += OnFetchMoreChannels;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnFetchMoreChannels -= OnFetchMoreChannels;
}
private void OnFetchMoreChannels(List<FetchChannelData> data, bool canLoadMore)
{
Debug.Log("FETCH MORE CHANNELS: CAN LOAD MORE: " + canLoadMore);
for (int i = 0; i < data.Count; i++)
{
Debug.Log("FETCH MORE CHANNELS: ID: " + data[i].id);
Debug.Log("FETCH MORE CHANNELS: NAME: " + data[i].name);
Debug.Log("FETCH MORE CHANNELS: DESCRIPTION: " + data[i].description);
Debug.Log("FETCH MORE CHANNELS: HAS PASSWORD: " + data[i].hasPassword);
Debug.Log("FETCH MORE CHANNELS: MEMBERS COUNT: " + data[i].membersCount);
Debug.Log("FETCH MORE CHANNELS: OWNER ID: " + data[i].ownerId);
Debug.Log("FETCH MORE CHANNELS: PROJECT ID: " + data[i].projectId);
for (int x = 0; x < data[i].tags.Length; x++)
{
Debug.Log("FETCH MORE CHANNELS: TAGS: " + data[i].tags[x]);
}
for (int a = 0; a < data[i].messageTags.Length; a++)
{
Debug.Log("FETCH MORE CHANNELS: MESSAGE TAGS: " + data[i].messageTags[a]);
}
Debug.Log("FETCH MORE CHANNELS: TEMPLATE ID: " + data[i].templateId);
Debug.Log("FETCH MORE CHANNELS: CAPACITY: " + data[i].capacity);
Debug.Log("FETCH MORE CHANNELS: VISIBLE: " + data[i].visible);
Debug.Log("FETCH MORE CHANNELS: PRIVATE: " + data[i].ch_private);
Debug.Log("FETCH MORE CHANNELS: PERMANENT: " + data[i].permanent);
Debug.Log("FETCH MORE CHANNELS: HAS PASSWORD: " + data[i].hasPassword);
Debug.Log("FETCH MORE CHANNELS: PASSWORD: " + data[i].password);
Debug.Log("FETCH MORE CHANNELS: IS JOINED: " + data[i].isJoined);
Debug.Log("FETCH MORE CHANNELS: IS INVITED: " + data[i].isInvited);
Debug.Log("FETCH MORE CHANNELS: IS MUTED: " + data[i].isMuted);
Debug.Log("FETCH MORE CHANNELS: IS REQUEST SENT: " + data[i].isRequestSent);
Debug.Log("FETCH MORE CHANNELS: MEMBERS COUNT: " + data[i].membersCount);
Debug.Log("FETCH MORE CHANNELS: OWNER ACL: " + JsonUtility.ToJson(data[i].ownerAcl));
Debug.Log("FETCH MORE CHANNELS: MEMBER ACL: " + JsonUtility.ToJson(data[i].memberAcl));
Debug.Log("FETCH MORE CHANNELS: GUEST ACL: " + JsonUtility.ToJson(data[i].guestAcl));
}
}
Execution with an error:
- JavaScript
- Unity
ss.channels.on('error:fetchMoreChannels', (err) => {
// Completed with an error
})
// subscribe to event
private void OnEnable()
{
SS_Channels.OnFetchMoreChannelsError += OnFetchMoreChannelsError;
}
// unsubscribe from event
private void OnDisable()
{
SS_Channels.OnFetchMoreChannelsError -= OnFetchMoreChannelsError;
}
// Completed with an error
private void OnFetchMoreChannelsError() => Debug.Log("FETCH MORE CHANNELS: ERROR");
Possible errors are given 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!