跳到主要内容

Client PersonalChat API Reference

The Personal Chat feature allows for one-on-one chat with other players.

API List

APIDescription
SendPersonalTextMsgSend personal chat text message
SendPersonalCustomMsgSend personal chat custom message
GetMyPersonalChatListGet my personal chat list
GetPersonalMsgListGet chat message list with a player
ActivePersonalChatActive a personal chat. When activated, OnUnreadPersonalMsgCountNotifyEvt will be pushed, and subsequent personal chat messages currently in progress are automatically marked as read
GetActivePersonalChatGet the activated personal chat.
ClearPersonalUnreadCountMark messages with someone as all read
RemovePersonalChatRemove a personal chat, all message with this player will be removed

Event List

EventDescription
SetOnUnreadPersonalMsgCountNotifyThe event will be triggered after login PGOS and when the unread count of personal message changed.
SetOnReceivePersonalMsgThe event will be triggered when receive personal chat message.

API Details

SendPersonalTextMsg

Send personal chat text message

/**
* Send personal chat text message
*
* @param params Request struct 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 SendPersonalTextMsg(
const SendPersonalMsgParams& params,
PgosDataCallback<PersonalMsgInfo> result_callback);

Parameters:

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

Return: void

SendPersonalCustomMsg

Send personal chat custom message

/**
* Send personal chat custom message
*
* @param params Request struct 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 SendPersonalCustomMsg(
const SendPersonalMsgParams& params,
PgosDataCallback<PersonalMsgInfo> result_callback);

Parameters:

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

Return: void

GetMyPersonalChatList

Get my personal chat list

/**
* Get my personal chat list
*
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void GetMyPersonalChatList(
PgosDataCallback<GetMyPersonalChatListResult> result_callback);

Parameters:

ParamTypeDescription
result_callbackPgosDataCallback<GetMyPersonalChatListResult>The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

GetPersonalMsgList

Get chat message list with a player

/**
* Get chat message list with a player
*
* @param peer_player_id The peer player ID
* @param start_seq The start sequence number of the message to query, 0 means start from the latest message.
* @param count The count of message to get
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void GetPersonalMsgList(
const pgos::pstring& peer_player_id,
int64_t start_seq,
int32_t count,
PgosDataCallback<GetPersonalChatMsgListResult> result_callback);

Parameters:

ParamTypeDescription
peer_player_idconst std::string&The peer player ID
start_seqint64_tThe start sequence number of the message to query, 0 means start from the latest message.
countint32_tThe count of message to get
result_callbackPgosDataCallback<GetPersonalChatMsgListResult>The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

ActivePersonalChat

Active a personal chat. When activated, OnUnreadPersonalMsgCountNotifyEvt will be pushed, and subsequent personal chat messages currently in progress are automatically marked as read

/**
* Active a personal chat. When activated, OnUnreadPersonalMsgCountNotifyEvt will be pushed, and subsequent personal chat messages currently in progress are automatically marked as read
*
* @param peer_player_id The player to set as active. If empty, it means no personal chat will be activated.
*/
void ActivePersonalChat(
const pgos::pstring& peer_player_id);

Parameters:

ParamTypeDescription
peer_player_idconst std::string&The player to set as active. If empty, it means no personal chat will be activated.

Return: void

GetActivePersonalChat

Get the activated personal chat.

/**
* Get the activated personal chat.
*
* @return Player ID of the activated personal chat. If empty, it means no personal chat is activated.
*/
pgos::pstring GetActivePersonalChat();

Parameters:

(No parameters)

Return: pgos::pstring

Player ID of the activated personal chat. If empty, it means no personal chat is activated.

ClearPersonalUnreadCount

Mark messages with someone as all read

/**
* Mark messages with someone as all read
*
* @param peer_player_id The player chat with. If empty, it means all players
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void ClearPersonalUnreadCount(
const pgos::pstring& peer_player_id,
PgosCallback result_callback);

Parameters:

ParamTypeDescription
peer_player_idconst std::string&The player chat with. If empty, it means all players
result_callbackPgosCallbackThe result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

RemovePersonalChat

Remove a personal chat, all message with this player will be removed

/**
* Remove a personal chat, all message with this player will be removed
*
* @param peer_player_id The personal chat to remove. If empty, it means all players
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void RemovePersonalChat(
const pgos::pstring& peer_player_id,
PgosCallback result_callback);

Parameters:

ParamTypeDescription
peer_player_idconst std::string&The personal chat to remove. If empty, it means all players
result_callbackPgosCallbackThe result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

Event Details

SetOnUnreadPersonalMsgCountNotify

The event will be triggered after login PGOS and when the unread count of personal message changed.

/**
* OnSetOnUnreadPersonalMsgCountNotify:
* The event will be triggered after login PGOS and when the unread count of personal message changed.
*
* @param event Event result of unread message count changed.
*/
void SetOnUnreadPersonalMsgCountNotify(
const UnreadMsgCountNotifyEvt& event);

Parameters:

ParamTypeDescription
eventconst UnreadMsgCountNotifyEvt&Event result of unread message count changed.

SetOnReceivePersonalMsg

The event will be triggered when receive personal chat message.

/**
* OnSetOnReceivePersonalMsg:
* The event will be triggered when receive personal chat message.
*
* @param event Event result of receive personal chat message.
*/
void SetOnReceivePersonalMsg(
const ReceivePersonalMsgEvt& event);

Parameters:

ParamTypeDescription
eventconst ReceivePersonalMsgEvt&Event result of receive personal chat message.