Lobby Chat Message Send API
Send a chat message to all users in the matchmaking lobby with the SDK.SendLobbyMsg method.
using Stove.PCSDK.NET.Matchmaking;
string lobby = this.lobby;
string message = "Chat message";
string myProfile = "http://ontove.myprofile";
SDK.SendLobbyMsg(lobby, message, myProfile);
Plain Text
복사
Chat messages are subject to bans. It sends messages filtered for nonsense words in the form "****". The last parameter (myProfile) transmits data without applying a ban. You can use it when sending JSON string / my profile URI.
Lobby Chat Message Sending/Receiving a callback
If an error occurs while the SDK.SendLobbyMsg method is running, you can check the contents in error.result (error code) StovePCMatchmakingResult.
To receive callbacks for lobby chat, you must register a delegate in advance.
It calls the OnSendLobbyMessage callback when I send a chat message to the lobby. It calls the OnRecvLobbyMessage callback when it receives another user's chat message in the lobby.
using Stove.PCSDK.NET.Matchmaking;
// Register lobby chat send a delegate
SDK.EventSendLobbyMessage += GameObj.OnSendLobbyMessage;
// Register the lobby chat receiving delegate
SDK.EventRecvLobbyMessage += GameObj.OnRecvLobbyMessage;
// send chat in lobby
private void OnSendLobbyMessage(StovePCMatchmakingError error, StovePCMatchmakingSendLobbyMessage sendLobbyMessage)
{
// process game logic
if (error.result == StovePCMatchmakingResult.NO_ERROR)
{
}
// error handling
else
{
StringBuilder sb = new StringBuilder();
// error code
sb.AppendFormat(" - fail code : {0}", error.result);
// If there is a specific error
sb.AppendFormat(" - fail message : {0}", error.message);
Debug.Log(sb.ToString());
}
}
// Receive chat in lobby
private void OnRecvLobbyMessage(StovePCMatchmakingError error, StovePCMatchmakingRecvLobbyMessage recvLobbyMessage)
{
// process game logic
if (error.result == StovePCMatchmakingResult.NO_ERROR)
{
}
// error handling
else
{
StringBuilder sb = new StringBuilder();
// error code
sb.AppendFormat(" - fail code : {0}", error.result);
// If there is a specific error
sb.AppendFormat(" - fail message : {0}", error.messa
ge);
Debug.Log(sb.ToString());
}
}
Plain Text
복사
You should call the RunCallback method periodically because the lobby may receive other user messages.