Skip to main content

Client InstantChat API Reference

Instant Chat is used for instant text chatting among multiple people. All players who join a given channel can chat with each other. When all the players in a chat leave the channel or go offline, the channel is automatically deleted.

API List

APIDescription
JoinInstantChatJoin a text channel chat.
LeaveInstantChatLeave a text channel chat.
SendInstantChatTextMsgSend instant text chat message.
SendInstantChatCustomMsgSend instant custom chat message.
GetInstantChatMembersGet all players in a channel.
GetInstantChatMemberIDsGet all player IDs in a channel.
GetInstantChatMemberCountGet the num of players in a channel.

Event List

EventDescription
SetOnReceiveInstantChatMsgThe event will be triggered when receive channel chat message.
SetOnInstantChatMemberJoinedThe event will be triggered when new players joined the chat channel.
SetOnInstantChatMemberLeftThe event will be triggered when player left the chat channel.

API Details

JoinInstantChat

Join a text channel chat.

/**
* Join a text channel chat.
*
* @param chat_channel_id A custom unique ID used to identify the channel (in game scope), must be 127 characters or less, can use battle-session-id which base on UUID with 36 characters.
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void JoinInstantChat(
const pgos::pstring& chat_channel_id,
PgosDataCallback<JoinInstantChatResult> result_callback);

Parameters:

ParamTypeDescription
chat_channel_idconst std::string&A custom unique ID used to identify the channel (in game scope), must be 127 characters or less, can use battle-session-id which base on UUID with 36 characters.
result_callbackPgosDataCallback<JoinInstantChatResult>The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

LeaveInstantChat

Leave a text channel chat.

/**
* Leave a text channel chat.
*
* @param chat_channel_id The chat channel id to leave.
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void LeaveInstantChat(
const pgos::pstring& chat_channel_id,
PgosCallback result_callback);

Parameters:

ParamTypeDescription
chat_channel_idconst std::string&The chat channel id to leave.
result_callbackPgosCallbackThe result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

SendInstantChatTextMsg

Send instant text chat message.

/**
* Send instant text chat message.
*
* @param params Request struct for sending instant chat message.
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void SendInstantChatTextMsg(
const SendInstantChatMsgParams& params,
PgosDataCallback<ChatMsgInfo> result_callback);

Parameters:

ParamTypeDescription
paramsconst SendInstantChatMsgParams&Request struct for sending instant chat message.
result_callbackPgosDataCallback<ChatMsgInfo>The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

SendInstantChatCustomMsg

Send instant custom chat message.

/**
* Send instant custom chat message.
*
* @param params Request struct for sending instant chat message.
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void SendInstantChatCustomMsg(
const SendInstantChatMsgParams& params,
PgosDataCallback<ChatMsgInfo> result_callback);

Parameters:

ParamTypeDescription
paramsconst SendInstantChatMsgParams&Request struct for sending instant chat message.
result_callbackPgosDataCallback<ChatMsgInfo>The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

GetInstantChatMembers

Get all players in a channel.

/**
* Get all players in a channel.
*
* @param chat_channel_id The chat channel id.
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void GetInstantChatMembers(
const pgos::pstring& chat_channel_id,
PgosDataCallback<GetInstantChatMembersResult> result_callback);

Parameters:

ParamTypeDescription
chat_channel_idconst std::string&The chat channel id.
result_callbackPgosDataCallback<GetInstantChatMembersResult>The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

GetInstantChatMemberIDs

Get all player IDs in a channel.

/**
* Get all player IDs in a channel.
*
* @param chat_channel_id The chat channel id.
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void GetInstantChatMemberIDs(
const pgos::pstring& chat_channel_id,
PgosDataCallback<GetInstantChatMemberIDsResult> result_callback);

Parameters:

ParamTypeDescription
chat_channel_idconst std::string&The chat channel id.
result_callbackPgosDataCallback<GetInstantChatMemberIDsResult>The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

GetInstantChatMemberCount

Get the num of players in a channel.

/**
* Get the num of players in a channel.
*
* @param chat_channel_id The chat channel id.
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void GetInstantChatMemberCount(
const pgos::pstring& chat_channel_id,
PgosDataCallback<GetInstantChatMemberCountResult> result_callback);

Parameters:

ParamTypeDescription
chat_channel_idconst std::string&The chat channel id.
result_callbackPgosDataCallback<GetInstantChatMemberCountResult>The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

Event Details

SetOnReceiveInstantChatMsg

The event will be triggered when receive channel chat message.

/**
* OnSetOnReceiveInstantChatMsg:
* The event will be triggered when receive channel chat message.
*
* @param event Event result of receive instant chat message.
*/
void SetOnReceiveInstantChatMsg(
const ReceiveInstantChatMsgEvt& event);

Parameters:

ParamTypeDescription
eventconst ReceiveInstantChatMsgEvt&Event result of receive instant chat message.

SetOnInstantChatMemberJoined

The event will be triggered when new players joined the chat channel.

/**
* OnSetOnInstantChatMemberJoined:
* The event will be triggered when new players joined the chat channel.
*
* @param event Event result of member joined instant chat.
*/
void SetOnInstantChatMemberJoined(
const InstantChatMemberJoinedEvt& event);

Parameters:

ParamTypeDescription
eventconst InstantChatMemberJoinedEvt&Event result of member joined instant chat.

SetOnInstantChatMemberLeft

The event will be triggered when player left the chat channel.

/**
* OnSetOnInstantChatMemberLeft:
* The event will be triggered when player left the chat channel.
*
* @param event Event result of member left instant chat.
*/
void SetOnInstantChatMemberLeft(
const InstantChatMemberLeftEvt& event);

Parameters:

ParamTypeDescription
eventconst InstantChatMemberLeftEvt&Event result of member left instant chat.