Members
Overview
When a player joins a guild, group chat or lobby, they become a channel member. The gameplay can be designed in such a way that the player will need to independently initiate or cancel the request to join the channel. A channel member can be excluded, muted, and so on.
The interaction of the member with the channel is, for example, a mechanism for submitting an application for entry into the clan
Below is a complete list of methods implemented to manage the channel participants:
gp.channels.join
- request for the introduction +1 Requestgp.channels.cancelJoin
- cancellation of the request to enter +1 Requestgp.channels.leave
- the exit of the participant from the channel +1 Requestgp.channels.kick
- exclusion of the participant from the channel +1 Requestgp.channels.mute
- mute player in channel +1 Requestgp.channels.unmute
- unmute a player +1 Request
Join a Channel
To join a channel, you must create a request to join. In this case, there can be two development scenarios:
- Channel is public. Anyone interested can join. Then the player automatically becomes a participant.
- Channel is private. A request to join is created, which must be accepted by the channel owner or any participant with proper permissions.
Request to Join a Channel
+1 RequestTo create a request to join a channel with the identifier channelId: 123
, use the gp.channels.join
method:
- JavaScript
- Unity
gp.channels.join({ channelId: 123 });
GP_Channels.Join(channel_ID: 123);
If a password is installed in the channel, then it should be transferred along with the identifier:
- JavaScript
- Unity
gp.channels.join({ channelId: 123, password: "qwerty" });
GP_Channels.Join(channel_ID: 123, password: "12345");
You can find out if a channel has a password using the gp.channels.fetchChannel({ channelId: 123 })
method and look at the channel.hasPassword field.
After calling the method, the player automatically joins the channel if the channel was public. If the channel is private, then a request to join is sent and must be accepted. To find out if a channel is private or not, you can look at the channel.private field.
To get the result of the method call, you can subscribe to events:
- JavaScript
- Unity
gp.channels.on("join", () => {
// Successfully entered or applied for the entry
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnJoinSuccess += OnJoinSuccess;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnJoinSuccess -= OnJoinSuccess;
}
// Successfully entered or applied for the entry
private void OnJoinSuccess() => Debug.Log("JOIN: SUCCESS");
Execution with an error:
- JavaScript
- Unity
gp.channels.on("error:join", (err) => {
// Completed with an error
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnJoinError += OnJoinError;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnJoinError -= OnJoinError;
}
// Completed with an error
private void OnJoinError() => Debug.Log("JOIN: 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 | already_in_channel |
player_banned | already_requested 💡 |
internal_error | channel_capacity_reached |
invalid_password 💡 | |
already_in_channel |
already_requested 💡 - already applied for membership. invalid_password 💡 - an error occurs if a password is set for the public channel and the password is incorrect. If the channel is private, then the password is ignored, since the request confirmation mechanism is used by the owner.
Having made a request to join a public channel, the player automatically becomes a member of it and all players in the channel receive a notification about joining:
- JavaScript
- Unity
gp.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()
{
GP_Channels.OnJoinEvent += OnJoinEvent;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnJoinEvent -= OnJoinEvent;
}
private void OnJoinEvent(GP_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);
}
Request to Join a Private Channel
All players in the channel (if they can accept join requests) are notified that a new player is trying to join the channel:
- JavaScript
- Unity
gp.channels.on("event:joinRequest", (joinRequest) => {
// Channel ID
joinRequest.channelId;
// The ID of the player who applied to join
joinRequest.playerId;
// Player fields (avatar, name, custom fields)
joinRequest.player;
// Date of the request to join in the format ISO 8601 UTC "2022-12-01T04:52:26+0000"
joinRequest.date;
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnJoinRequest += OnJoinRequest;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnJoinRequest -= OnJoinRequest;
}
private void OnJoinRequest(GP_Data data)
{
var joinRequestData = data.Get<JoinRequestData>();
Debug.Log("JOIN REQUEST EVENT: CHANNEL ID: " + joinRequestData.channelId);
Debug.Log("JOIN REQUEST EVENT: ID: " + joinRequestData.playerId);
Debug.Log("JOIN REQUEST EVENT: DATE: " + joinRequestData.date);
Debug.Log("JOIN REQUEST EVENT: PLAYER STATE: AVATAR: " + joinRequestData.player.avatar);
Debug.Log("JOIN REQUEST EVENT: PLAYER STATE: CREDITIALS: " + joinRequestData.player.credentials);
Debug.Log("JOIN REQUEST EVENT: PLAYER STATE: ID: " + joinRequestData.player.id);
Debug.Log("JOIN REQUEST EVENT: PLAYER STATE: NAME: " + joinRequestData.player.name);
Debug.Log("JOIN REQUEST EVENT: PLAYER STATE: PLATFORM TYPE: " + joinRequestData.player.platformType);
Debug.Log("JOIN REQUEST EVENT: PLAYER STATE: PROJECT ID: " + joinRequestData.player.projectId);
Debug.Log("JOIN REQUEST EVENT: PLAYER STATE: SCORE: " + joinRequestData.player.score);
}
Players can accept the request using the acceptJoinRequest
method or reject it via rejectJoinRequest
(see the Requests section for more details)).
Cancel Request to Join
+1 RequestTo cancel a request to join a channel with identifier channelId: 123
, use the gp.channels.cancelJoin
method:
- JavaScript
- Unity
gp.channels.cancelJoin({ channelId: 123 });
GP_Channels.CancelJoin(channel_ID: 123);
To get the result of a method call, you can subscribe to events:
- JavaScript
- Unity
gp.channels.on("cancelJoin", () => {
// Successfully canceled the application for membership
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnCancelJoinSuccess += OnCancelJoinSuccess;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnCancelJoinSuccess -= OnCancelJoinSuccess;
}
// Successfully canceled the application for membership
private void OnCancelJoinSuccess() => Debug.Log("CANCEL JOIN: SUCCESS");
Execution with an error:
- JavaScript
- Unity
gp.channels.on("error:cancelJoin", (err) => {
// Completed with an error
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnCancelJoinError += OnCancelJoinError;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnCancelJoinError -= OnCancelJoinError;
}
private void OnCancelJoinError() => Debug.Log("CANCEL JOIN: 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 | join_request_not_found 💡 |
player_banned | |
internal_error |
join_request_not_found 💡 - the player did not apply for membership or canceled it
If a player cancels a channel join request, all players in the channel (if they can accept join requests) are notified that the join request has been cancelled:
- JavaScript
- Unity
gp.channels.on("event:cancelJoin", (joinRequest) => {
// Channel ID
joinRequest.channelId;
// ID of the player who applied to join
joinRequest.playerId;
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnCancelJoinEvent += OnCancelJoinEvent;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnCancelJoinEvent -= OnCancelJoinEvent;
}
private void OnCancelJoinEvent(CancelJoinData data)
{
Debug.Log("CANCEL JOIN EVENT: CHANNEL ID: " + data.channelId);
Debug.Log("CANCEL JOIN EVENT: PLAYER ID: " + data.playerId);
}
Channel Leave
+1 RequestTo leave a channel with channelId: 123
:
- JavaScript
- Unity
gp.channels.leave({ channelId: 123 });
GP_Channels.Leave(channel_ID: 123);
To get the result of a method call, you can subscribe to events:
- JavaScript
- Unity
gp.channels.on("leave", () => {
// Successfully left the channel
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnLeaveSuccess += OnLeaveSuccess;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnLeaveSuccess -= OnLeaveSuccess;
}
// Successfully left the channel
private void OnLeaveSuccess() => Debug.Log("ON LEAVE CHANNEL: SUCCESS");
Execution with an error:
- JavaScript
- Unity
gp.channels.on("error:leave", (err) => {
// Completed with an error
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnLeaveError += OnLeaveError;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnLeaveError -= OnLeaveError;
}
// Completed with an error
private void OnLeaveError() => Debug.Log("ON LEAVE CHANNEL: 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 | player_not_in_channel |
player_banned | |
internal_error |
The player leaves the channel, and all players in the channel are notified about this event:leave
event:
- JavaScript
- Unity
gp.channels.on("event:leave", (memberLeave) => {
// Channel ID
memberLeave.channelId;
// ID of the leave player
memberLeave.playerId;
// The reason for the exit: "leave"
memberLeave.reason;
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnLeaveEvent += OnLeaveEvent;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnLeaveEvent -= OnLeaveEvent;
}
private void OnLeaveEvent(MemberLeaveData data)
{
Debug.Log("ON LEAVE CHANNEL: CHANNEL ID: " + data.channelId);
Debug.Log("ON LEAVE CHANNEL: PLAYER ID: " + data.playerId);
Debug.Log("ON LEAVE CHANNEL: REASON: " + data.reason);
}
Remove a Member from a Channel
+1 RequestThe owner of the channel cannot be remove from the channel
To exclude member playerId: 123456
from channel channelId: 123
:
- JavaScript
- Unity
gp.channels.kick({ channelId: 123, playerId: 123456 });
GP_Channels.Kick(channel_ID: 123, player_ID: 123456);
To get the result of the method call, you can subscribe to events:
- JavaScript
- Unity
gp.channels.on("kick", () => {
// Successfully excluded
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnKick += OnKick;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnKick -= OnKick;
}
// Successfully excluded
private void OnKick() => Debug.Log("KICK: SUCCESS");
Execution with an error:
- JavaScript
- Unity
gp.channels.on("error:kick", (err) => {
// Completed with an error
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnKickError += OnKickError;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnKickError -= OnKickError;
}
// Completed with an error
private void OnKickError() => Debug.Log("KICK: 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 | player_not_in_channel |
internal_error |
The player leaves the channel and all players in the channel are notified of this event:leave
event:
- JavaScript
- Unity
gp.channels.on("event:leave", (memberLeave) => {
// Channel ID
memberLeave.channelId;
// ID of the leave player
memberLeave.playerId;
// The reason for the leave: "Kick"
memberLeave.reason;
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnLeaveEvent += OnLeaveEvent;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnLeaveEvent -= OnLeaveEvent;
}
private void OnLeaveEvent(MemberLeaveData data)
{
Debug.Log("ON LEAVE CHANNEL: CHANNEL ID: " + data.channelId);
Debug.Log("ON LEAVE CHANNEL: PLAYER ID: " + data.playerId);
Debug.Log("ON LEAVE CHANNEL: REASON: " + data.reason);
}
Fetch Members
+1 RequestYou can see all the players (members) in the desired channel and get all their public data. By joining the chat, the player will see all its participants:
- JavaScript
- Unity
const response = await gp.channels.fetchMembers({
channelId: 10,
// Optional
// Search by ID or name or ID on the site
search: "",
// Search only those on the network
onlyOnline: 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 FetchMembers()
{
var filter = new FetchMembersFilter(Channel_ID: 10);
// Search by ID or name or ID on the site
filter.search = "friend";
// Search only those on the network
filter.onlyOnline = true;
// How much to request at a time, Max.100
filter.limit = 50;
// How many records can be missed, Max.10,000, used for page navigation or "load more"
filter.offset = 0;
GP_Channels.FetchMembers(filter);
}
To get the result of a method call, you can subscribe to events:
- JavaScript
- Unity
gp.channels.on("fetchMembers", (result) => {
result.items; // An array of the list of participants
result.canLoadMore; // Is it possible to load more participants
result.items.forEach((member) => {
// All fields of the participant
// ID player
member.id;
// Now online
member.isOnline;
// Public fields of the player
member.state;
// For example, name, avatar and score
member.state.name;
member.state.avatar;
member.state.score;
// Information about the player's MUT
member.mute;
// Depressed or not
member.mute.isMuted;
// Meta removal time - Date in ISO 8601, if an empty line is eternal
member.mute.unmuteAt;
});
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnFetchMembers += OnFetchMembers;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnFetchMembers -= OnFetchMembers;
}
private void OnFetchMembers(GP_Data data, bool canLoadMore)
{
var membersData = data.GetList<FetchMembersData>();
Debug.Log("FETCH MEMBERS: CAN LOAD MORE: " + canLoadMore);
for (int i = 0; i < membersData.Count; i++)
{
Debug.Log("FETCH MEMBERS: MEMBER: ID: " + membersData[i].id);
Debug.Log("FETCH MEMBERS: MEMBER: IS ONLINE: " + membersData[i].isOnline);
Debug.Log("FETCH MEMBERS: MEMBER: IS MUTED: " + membersData[i].mute.isMuted);
// Meta removal time - Date in ISO 8601, if an empty line is eternal
Debug.Log("FETCH MEMBERS: MEMBER: UNMUTE AT: " + membersData[i].mute.unmuteAt);
Debug.Log("FETCH MEMBERS: MEMBER: AVATAR: " + membersData[i].state.avatar);
Debug.Log("FETCH MEMBERS: MEMBER: CREDITIALS: " + membersData[i].state.credentials);
Debug.Log("FETCH MEMBERS: MEMBER: ID: " + membersData[i].state.id);
Debug.Log("FETCH MEMBERS: MEMBER: NAME: " + membersData[i].state.name);
Debug.Log("FETCH MEMBERS: MEMBER: PLATFORM TYPE: " + membersData[i].state.platformType);
Debug.Log("FETCH MEMBERS: MEMBER: PROJECT ID: " + membersData[i].state.projectId);
Debug.Log("FETCH MEMBERS: MEMBER: SCORE: " + membersData[i].state.score);
}
}
Execution with an error:
- JavaScript
- Unity
gp.channels.on("error:fetchMembers", (err) => {
// Completed with an error
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnFetchMembersError += OnFetchMembersError;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnFetchMembersError -= OnFetchMembersError;
}
// Completed with an error
private void OnFetchMembersError() => Debug.Log("FETCH MEMBERS: 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 | |
player_banned | |
internal_error |
To additionally load the participants for the same request, there is a convenient method:
- JavaScript
- Unity
const response = await gp.channels.fetchMoreMembers({
channelId: 10,
// Optional
// Search by ID or name or ID on the site
search: "",
// Search only those on the network
onlyOnline: true,
// How much to request at a time, Max.100
limit: 100,
});
public void FetchMoreMembers()
{
var filter = new FetchMoreMembersFilter(Channel_ID: 10);
// Search by ID or name or ID on the site
filter.search = "friend";
// Search only those on the network
filter.onlyOnline = true;
// How much to request at a time, Max.100
filter.limit = 50;
GP_Channels.FetchMoreMembers(filter);
}
To get the result of the method call, you can subscribe to events:
- JavaScript
- Unity
gp.channels.on("fetchMoreMembers", (result) => {
result.items; // An array of the list of participants
result.canLoadMore; // Is it possible to load more participants
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnFetchMoreMembers += OnFetchMoreMembers;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnFetchMoreMembers -= OnFetchMoreMembers;
}
private void OnFetchMoreMembers(GP_Data data, bool canLoadMore)
{
var membersData = data.GetList<FetchMembersData>();
Debug.Log("FETCH MORE MEMBERS: CAN LOAD MORE: " + canLoadMore);
for (int i = 0; i < membersData.Count; i++)
{
Debug.Log("FETCH MORE MEMBERS: MEMBER: ID: " + membersData[i].id);
Debug.Log("FETCH MORE MEMBERS: MEMBER: IS ONLINE: " + membersData[i].isOnline);
Debug.Log("FETCH MORE MEMBERS: MEMBER: IS MUTED: " + membersData[i].mute.isMuted);
Debug.Log("FETCH MORE MEMBERS: MEMBER: UNMUTE AT: " + membersData[i].mute.unmuteAt);
Debug.Log("FETCH MORE MEMBERS: MEMBER: AVATAR: " + membersData[i].state.avatar);
Debug.Log("FETCH MORE MEMBERS: MEMBER: CREDITIALS: " + membersData[i].state.credentials);
Debug.Log("FETCH MORE MEMBERS: MEMBER: ID: " + membersData[i].state.id);
Debug.Log("FETCH MORE MEMBERS: MEMBER: NAME: " + membersData[i].state.name);
Debug.Log("FETCH MORE MEMBERS: MEMBER: PLATFORM TYPE: " + membersData[i].state.platformType);
Debug.Log("FETCH MORE MEMBERS: MEMBER: PROJECT ID: " + membersData[i].state.projectId);
Debug.Log("FETCH MORE MEMBERS: MEMBER: SCORE: " + membersData[i].state.score);
}
}
Execution with an error:
- JavaScript
- Unity
gp.channels.on("error:fetchMoreMembers", (err) => {
// Completed with an error
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnFetchMoreMembersError += OnFetchMoreMembersError;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnFetchMoreMembersError -= OnFetchMoreMembersError;
}
// Completed with an error
private void OnFetchMoreMembersError() => Debug.Log("FETCH MORE MEMBERS: 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 | |
player_banned | |
internal_error |
Mute Player 🔇
+1 Request/mute. The owner of the channel cannot be mute
To mute the player playerId: 123456
in the channel channelId: 123
use the gp.channels.mute
method:
- JavaScript
- Unity
gp.channels.mute({
channelId: 123,
playerId: 123456,
unmuteAt: "2022-12-01T04:52:26+0000",
});
GP_Channels.Mute(channel_ID: 123, player_ID: 123456, unmuteAt: "2022-12-01T04:52:26+0000");
An alternative option with the ability to set the number of seconds for which you want to mute the player:
- JavaScript
- Unity
// mute on 5 minutes
gp.channels.mute({ channelId: 123, playerId: 123456, seconds: 5 * 60 });
// mute on 5 minutes
GP_Channels.Mute(channel_ID: 123, player_ID: 123456, seconds: 5 * 60);
The developer independently sets the time for which the player should be muted using unmuteAt
. If no unmuteAt
value is passed, the player is muted indefinitely.
To get the result of the method call, you can subscribe to events:
- JavaScript
- Unity
gp.channels.on("mute", () => {
// Successfully muted
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnMuteSuccess += OnMuteSuccess;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnMuteSuccess -= OnMuteSuccess;
}
// Successfully muted
private void OnMuteSuccess() => Debug.Log("MUTE: SUCCESS");
Execution with an error:
- JavaScript
- Unity
gp.channels.on("error:mute", (err) => {
// Completed with an error
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnMuteError += OnMuteError;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnMuteError -= OnMuteError;
}
// Completed with an error
private void OnMuteError() => Debug.Log("MUTE: 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 | wrong_time_format 💡 |
internal_error |
wrong_time_format 💡 - the incorrect format of the release of the lock
When a player is muted, all members in the channel receive a notification:
- JavaScript
- Unity
gp.channels.on("event:mute", (mute) => {
// Channel ID
mute.channelId;
// ID of mute player
mute.playerId;
// Date of unmute
mute.unmuteAt;
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnMuteEvent += OnMuteEvent;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnMuteEvent -= OnMuteEvent;
}
private void OnMuteEvent(MuteData data)
{
Debug.Log("MUTE EVENT: CHANNEL ID: " + data.channelId);
Debug.Log("MUTE EVENT: PLAYER ID: " + data.playerId);
Debug.Log("MUTE EVENT: UNMUTE AT: " + data.unmuteAt);
}
Unmute a Player 🔉
+1 Request/unmute
You can re-allow the player playerId: 123456
to write a message in the channel channelId: 123
using the gp.channels.unmute
method:
- JavaScript
- Unity
gp.channels.unmute({ channelId: 123, playerId: 123456 });
GP_Channels.UnMute(channel_ID: 123, player_ID: 123456);
To get the result of the method call, you can subscribe to events:
- JavaScript
- Unity
gp.channels.on("unmute", () => {
// Successfully unmuted
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnUnmuteSuccess += OnUnmuteSuccess;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnUnmuteSuccess -= OnUnmuteSuccess;
}
// Successfully unmuted
private void OnUnmuteSuccess() => Debug.Log("UNMUTE: SUCCESS");
Execution with an error:
- JavaScript
- Unity
gp.channels.on("error:unmute", (err) => {
// Completed with an error
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnUnmuteError += OnUnmuteError;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnUnmuteError -= OnUnmuteError;
}
// Completed with an error
private void OnUnmuteError() => Debug.Log("UNMUTE: 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 | not_muted |
internal_error |
At the same time, all members in the channel receive a notification:
- JavaScript
- Unity
gp.channels.on("event:unmute", (mute) => {
// Channel ID
mute.channelId;
// ID of unmute player
mute.playerId;
});
// subscribe to event
private void OnEnable()
{
GP_Channels.OnUnmuteEvent += OnUnmuteEvent;
}
// unsubscribe from event
private void OnDisable()
{
GP_Channels.OnUnmuteEvent -= OnUnmuteEvent;
}
private void OnUnmuteEvent(UnmuteData data)
{
Debug.Log("UNMUTE EVENT: CHANNEL ID: " + data.channelId);
Debug.Log("UNMUTE EVENT: PLAYER ID: " + data.playerId);
}
Stay in Touch
Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.
GamePush Community Telegram
: @gs_community.
For your suggestions e-mail
: [email protected]
We Wish you Success!