Channel
You can implement channel joins and exits. You can also use callback when a new user joins or exits the channel.
tip
When language-specific (language
) channel group has been set in the console, the user automatically enters the channel according to their language when they enter the chat server. To configure the automatic channel group, check the console guide documentation
caution
You cannot use language
, country
, countrycode
, guild
, and whisper
as channel group names. These are reserved words used in the Auto Create Channel function.
Description
The following details callback methods, call methods, and information classes related to the channel.
Callback method
// This callback method is relayed when a user joins a channel. It transfers the channel's information.
void OnJoinChannel(BackndChat::ChannelInfo channelInfo) { }
// This callback method is relayed when a user exits a channel. It transfers the channel's information.
void OnLeaveChannel(BackndChat::ChannelInfo channelInfo) { }
// This callback method is relayed when a new user connects to a channel. It transfers the user's information.
void OnJoinChannelPlayer(string channelGroup, string channelName, uint64_t channelNumber, string gamerName, string avatar) { }
// This callback method is relayed when a user exits a channel. It transfers the user's information.
void OnLeaveChannelPlayer(string channelGroup, string channelName, uint64_t channelNumber, string gamerName, string avatar) { }
Call methods
// Only private channels can be created in an SDK.
// You will need to use the console for other channel types.
// This is the method that creates private channels. It inserts and delivers the channel group, channel number, channel name, maximum users, and password.
// If you do not enter a password, the channel will be created as a public channel.
// If the channel number is sent as 0, the server automatically grants the channel number.
BackndChat::BDChatMain::SendCreatePrivateChannel(string channelGroup, uint64_t channelNumber = 0, string channelName = "default", uint32_t maxCount = 50, string password = "");
// This is the channel join method of the open channel type. It passes the channel group and the channel's name as arguments.
BackndChat::BDChatMain::SendJoinOpenChannel(string channelGroup, string channelName);
// This is the channel join method of the private channel type. It passes the channel group and the channel's number as arguments.
BackndChat::BDChatMain::SendJoinPrivateChannel(string channelGroup, uint64_t channelNumber, string password = "");
// This is the channel exit method. It passes the channel group, channel name, and channel number as arguments.
BackndChat::BDChatMain::SendLeaveChannel(string channelGroup, string channelName, uint64_t channelNumber);
Information classes
struct PlayerInfo
{
// Player name
string GamerName;
// Player avatar name
string Avatar;
};
struct ChannelInfo
{
// Channel group name
string ChannelGroup;
// Channel name
string ChannelName;
// Channel number
uint64_t ChannelNumber;
// Channel's max number of users
uint32_t MaxCount;
// Information of currently logged-in players
map<string, PlayerInfo> Players;
// List of chat messages
vector<MessageInfo> Messages;
};