Personal Chat
Last updated on
Players can communicate with other players using personal chat.
Send a Personal Chat
A player can send a personal message to any other player, if they know their User ID.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetPrivateMessageResponseDelegate(AccelByte::Api::Lobby::FPersonalChatResponse::CreateLambda([](const FAccelByteModelsPersonalMessageResponse& Result)
{
if (Result.Code == "0")
{
// Do something if SendPrivateMessage has been successful
}
else
{
// Do something if SendPrivateMessage has an error
}
}));
FString UserId = FString("SomeTargetUserId");
FString Message = FString("Your Message");
FRegistry::Lobby.SendPrivateMessage(UserId, Message);
string userId = "SomeTargetUserId";
string message = "Your Message";
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().SendPersonalChat(userId, message, result =>
{
if (result.IsError)
{
// Do something if SendPersonalChat has an error
Debug.Log($"Error SendPersonalChat, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if SendPersonalChat has been successful
}
});
Receive a Personal Chat
Personal chats can be received by registering to the personal chat event.
- Unreal Engine
- Unity
FRegistry::Lobby.SetPrivateMessageNotifDelegate(AccelByte::Api::Lobby::FPersonalChatNotif::CreateLambda([](const FAccelByteModelsPersonalMessageNotice& Result)
{
// Do something if PrivateMessageNotifDelegate has been retrieved successfully
}));
AccelBytePlugin.GetLobby().PersonalChatReceived += result =>
{
if (result.IsError)
{
// Do something if PersonalChatReceived has an error
Debug.Log($"Error PersonalChatReceived, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if PersonalChatReceieved has been successful
}
};