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
| API | Description |
|---|---|
| JoinInstantChat | Join a text channel chat. |
| LeaveInstantChat | Leave a text channel chat. |
| SendInstantChatTextMsg | Send instant text chat message. |
| SendInstantChatCustomMsg | Send instant custom chat message. |
| GetInstantChatMembers | Get all players in a channel. |
| GetInstantChatMemberIDs | Get all player IDs in a channel. |
| GetInstantChatMemberCount | Get the num of players in a channel. |
Event List
| Event | Description |
|---|---|
| SetOnReceiveInstantChatMsg | The event will be triggered when receive channel chat message. |
| SetOnInstantChatMemberJoined | The event will be triggered when new players joined the chat channel. |
| SetOnInstantChatMemberLeft | The 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:
| Param | Type | Description |
|---|---|---|
| chat_channel_id | const 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_callback | PgosDataCallback<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:
| Param | Type | Description |
|---|---|---|
| chat_channel_id | const std::string& | The chat channel id to leave. |
| result_callback | PgosCallback | The 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:
| Param | Type | Description |
|---|---|---|
| params | const SendInstantChatMsgParams& | Request struct for sending instant chat message. |
| result_callback | PgosDataCallback<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:
| Param | Type | Description |
|---|---|---|
| params | const SendInstantChatMsgParams& | Request struct for sending instant chat message. |
| result_callback | PgosDataCallback<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:
| Param | Type | Description |
|---|---|---|
| chat_channel_id | const std::string& | The chat channel id. |
| result_callback | PgosDataCallback<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:
| Param | Type | Description |
|---|---|---|
| chat_channel_id | const std::string& | The chat channel id. |
| result_callback | PgosDataCallback<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:
| Param | Type | Description |
|---|---|---|
| chat_channel_id | const std::string& | The chat channel id. |
| result_callback | PgosDataCallback<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:
| Param | Type | Description |
|---|---|---|
| event | const 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:
| Param | Type | Description |
|---|---|---|
| event | const 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:
| Param | Type | Description |
|---|---|---|
| event | const InstantChatMemberLeftEvt& | Event result of member left instant chat. |