跳到主要内容

Client PublicChat API Reference

The Public Chat is a service that allows all the players to join the same global chat channel and take free talk with each other.

API List​

APIDescription
JoinPublicChatJoin a public chat.
LeavePublicChatLeave a public chat.
SendPublicChatTextMsgSend public chat text message.
SendPublicChatCustomMsgSend public chat custom message.
GetPublicChatMentionedInfoGet latest record mentioning me in the channel.
ClearPublicChatMentionedInfoClear record mentioning me in the channel.

Event List​

EventDescription
SetOnReceivePublicChatMsgThe event will be triggered when receive public chat message.
SetOnPublicChatNewMentionedThe event will be triggered when a new mention of a channel is received.

API Details​

JoinPublicChat​

Join a public chat.

/**
* Join a public chat.
*
* @param channel_name The name of the channel to join which can be retrieved from the portal, currently only the name 'Default' is valid.
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void JoinPublicChat(
const pgos::pstring& channel_name,
PgosDataCallback<JoinPublicChatResult> result_callback);

Parameters:

ParamTypeDescription
channel_nameconst std::string&The name of the channel to join which can be retrieved from the portal, currently only the name 'Default' is valid.
result_callbackPgosDataCallback<JoinPublicChatResult>The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

LeavePublicChat​

Leave a public chat.

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

Parameters:

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

Return: void

SendPublicChatTextMsg​

Send public chat text message.

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

Parameters:

ParamTypeDescription
paramsconst SendPublicChatMsgParams&Request parameters for sending text message.
result_callbackPgosDataCallback<SendPublicChatMsgResult>The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

SendPublicChatCustomMsg​

Send public chat custom message.

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

Parameters:

ParamTypeDescription
paramsconst SendPublicChatMsgParams&Request parameters for sending custom message.
result_callbackPgosDataCallback<SendPublicChatMsgResult>The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

GetPublicChatMentionedInfo​

Get latest record mentioning me in the channel.

/**
* Get latest record mentioning me in the channel.
*
* @param channel_name The name of the channel.
* @param dst The latest record mentioned me.
* @return True if there are any mentions of me.
*/
bool GetPublicChatMentionedInfo(
const pgos::pstring& channel_name,
PublicChatMentionedInfo& dst);

Parameters:

ParamTypeDescription
channel_nameconst std::string&The name of the channel.
dstPublicChatMentionedInfo&The latest record mentioned me.

Return: bool

True if there are any mentions of me.

ClearPublicChatMentionedInfo​

Clear record mentioning me in the channel.

/**
* Clear record mentioning me in the channel.
*
* @param channel_name The name of the channel. If empty, it means all channels.
*/
void ClearPublicChatMentionedInfo(
const pgos::pstring& channel_name);

Parameters:

ParamTypeDescription
channel_nameconst std::string&The name of the channel. If empty, it means all channels.

Return: void

Event Details​

SetOnReceivePublicChatMsg​

The event will be triggered when receive public chat message.

/**
* OnSetOnReceivePublicChatMsg:
* The event will be triggered when receive public chat message.
*
* @param event Result of the event receive public chat message.
*/
void SetOnReceivePublicChatMsg(
const ReceivePublicChatMsgEvt& event);

Parameters:

ParamTypeDescription
eventconst ReceivePublicChatMsgEvt&Result of the event receive public chat message.

SetOnPublicChatNewMentioned​

The event will be triggered when a new mention of a channel is received.

/**
* OnSetOnPublicChatNewMentioned:
* The event will be triggered when a new mention of a channel is received.
*
* @param event Event results received for new channel mentions.
*/
void SetOnPublicChatNewMentioned(
const PublicChatNewMentionedEvt& event);

Parameters:

ParamTypeDescription
eventconst PublicChatNewMentionedEvt&Event results received for new channel mentions.