//////////
Search
Duplicate

9. Send/Receive Matchmaking Lobby Data

태그

Lobby Data Transfer API

Send data to all users in the matchmaking lobby with the SDK.SendLobbyBinarydata method.
using Stove.PCSDK.NET.Matchmaking; string lobby = this.lobby; byte[] data = new byte[5]{ (byte)'h', (byte)'e', (byte)'l', (byte)'l', (byte)'o', }; string myProfile = "http://ontove.myprofile"; SDK.SendLobbyBinarydata(lobby, data, myProfile);
Plain Text
복사
Data is not subject to kinks. The last parameter (myProfile) transmits information, and you can use it when sending JSON string / my profile URI.

Lobby data sending/receiving callback

If an error occurs while the SDK.SendLobbyBinarydata method is running, you can check the contents in error.result (error code) StovePCMatchmakingResult.
You must register a delegate in advance to receive callbacks for lobby data.
When I send data to the lobby, it calls the OnSendLobbyBinarydata callback. It calls the OnRecvLobbyBinarydata callback when receiving data from another user in the lobby.
using Stove.PCSDK.NET.Matchmaking; // Register the lobby data transfer delegate SDK.EventSendLobbyBinarydata += GameObj.OnSendLobbyBinarydata; // Register the lobby data receiving delegate SDK.EventRecvLobbyBinarydata += GameObj.OnRecvLobbyBinarydata; // send data from lobby private void OnSendLobbyBinarydata(StovePCMatchmakingError error, StovePCMatchmakingSendLobbyBinarydata sendLobbyBinarydata) { // 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 data from lobby private void OnRecvLobbyMessage(StovePCMatchmakingError error, StovePCMatchmakingRecvLobbyBinarydata recvLobbyBinarydata) { // 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()); } }
Plain Text
복사
You should call the RunCallback method periodically because the lobby can receive other user data.