# Matchmaking SDK Guide
# Multiplayer Overview
The STOVE game platform provides matchmaking, chat rooms, friend lists, moderator functions, and related APIs that you can apply to games in a multiplayer environment. Among them, the matchmaking system is a service that allows users to enjoy games together. It provides low network latency regardless of where various game users access from any region. It gathers game users in a shared space (matching). Chat messages and data are transmitted and transferred to game users connected to play games together in real-time.
We provide various network services to send chat messages and data to matched game users in real-time.
- Supports sending real-time chat messages through encrypted and secure sessions.
- Supports peer-to-peer networking for real-time data transmission of small games.
- Supports UDP relay for games where real-time transmission is essential, such as battles and FPS.
Developers only need to select which network service to use and which service to use.
# Introduction to Multiplayer
The matchmaking system consists of a matchmaking server and a client SDK.
You can register your game with the matchmaking server through the Game Services>Matchmaking
menu on STOVE Studio (opens new window), and develop game user matching with the Matchmaking Client SDK.
The role of the matchmaking system is to bring individual game players or their friends together in one place (the lobby) to enjoy the game together. The matchmaking system collects game users (the lobby) through three methods. It relays them so that they can enjoy the game together.
- The first method is random matching. Game users request quick entry to the matchmaking server. The server automatically directs users to the appropriate lobby and matches them. This method is easy to develop and can simplify the game user UI.
- The second method is search matching. Game users can set search conditions according to the characteristics defined in each game and select a list of lobbies that satisfy the requirements. In this way, It matches players of the same level as possible to develop a game that they can play at an appropriate difficulty level.
- The third method is to invite friends. Game users can invite their friends to play games together in the lobby I entered.
The matchmaking client SDK (Unity) makes it easy to apply the matchmaking system to your game.
# Matchmaking Random Matching Process
The following is how to play a game by randomly matching after connecting to the matchmaking server.
- Select the kind of multiplayer you want to play in the game. (ex. Difficulty: [Easy, Hard], Scenario: [Map 1, Map 2] )
- Enter the game lobby by calling the lobby random entry API with one of the values selected by the game user.
- When a game user calls the lobby random entry API with the following values (difficulty = easy and scenario = map 1), it automatically finds and enters a lobby or creates a lobby.
- Wait until it reaches the minimum number of players required to start the game.
- It transmits data on character or user settings between game users who enter the lobby.
- Chat API is provided to allow conversations between game users.
- The lobby manager will start the game when the game is ready to start.
- You can send and receive game data through the data transmission API. (P2P or UDP relay)
- When the game ends, the lobby manager ends the game, and the lobby automatically disappears.
# Install the Unity package
- Download Matchmaking SDK
- After downloading the matchmaking SDK, import
Matchmaking_develop.unitypackage
into Unity to easily configure the difficulty, mode, room, stage, and item to play in the Unity editor without entering any code.
Depending on your game style, configure it according to the description below.
# Create a Unity project
# Importing the Unity package
Menu - Assets - Import Package - Custom Package - Select Matchmaking_develop.unitypackage from folder
select import
# Register the app
- Register the game ID, app key, app secret, etc. issued by the STOVE Studio (opens new window)
Scenes folder - 01_LoginScene - Select StoveEssentialManager
# DifficultySetting
- Create/select a difficulty setting file
Select Menu - MakeSetting - DefficultySetting
- Difficulty setting
- +/- - Add/Remove
- Value - meta value for SDK communication (can be modified as arbitrary value, value cannot be duplicated)
- Name - The name to be displayed in the UI
- IsDefault - Whether to select the default (if there are multiple, use the first one)
- ResourcePath - The resource path to be displayed in the UI
- Settings applied in game
# RoomSettings
- Create/select a room setting file
Select Menu - MakeSetting - RoomSetting
- Room Setup
- +/- - Add/Remove
- Value - meta value for SDK communication (can be modified as arbitrary value, you cannot duplicate value)
- MaxUser - Maximum number of people
- Name - The Name to be displayed in the UI
- ResourcePath - The resource path displayed in the UI
# ModeSetting
- Create/select a mod setting file
Select Menu - MakeSetting - ModeSetting
- Mode setting
- +/- - Add/Remove
- Value - meta value for SDK communication (can be modified as arbitrary value, value cannot be duplicated)
- Name - The name to be displayed in the UI
- IsDefault - Whether to select the default (if there are multiple, use the first one)
- ResourcePath - The resource path to be displayed in the UI
- IsBattle - Whether or not there is a battle mode (the UI of the lobby changes depending on the mode)
- RoomValues - The value of RoomSetting used in the mode (can be added/removed)
- Settings applied in game
The room information used for the mode changes depending on the mode selection.
# StageSetting
- Create/select stage setting file
Select Menu - MakeSetting - StageSetting
- Stage Setup
- +/- - Add/Remove
- Value - meta value for SDK communication (can be modified as arbitrary value, you cannot duplicate value)
- Name - The Name to be displayed in the UI
- IsDefault - Whether to select the default (multiple days) use the first one)
- ResourcePath - The resource path displayed in the UI
# ItemSetting
- Create/select item setting file
Select Menu - MakeSetting - ItemSetting
- Item setting
- +/- - Add/Remove
- Value - meta value for SDK communication (can be modified as arbitrary value, you cannot duplicate value)
- Name - The Name to be displayed in the UI
- ResourcePath - The resource path displayed in the UI
- ItemType – Used as a meta key for item type identifier and SDK communication (optional value 6) can be modified, you cannot duplicate value)
- Settings applied in game
It automatically creates a toggle menu according to the item type and displays the type items in the list.
# Unity C# Code Guide
Describes how to use the Matchmaking SDK (Unity).
# 1) Initialize matchmaking
# Call the initialization method
After filling in the necessary values to initialize the matchmaking SDK, call the SDK.Initialize
method.
using Stove.PCSDK.NET.Matchmaking;
bool result = SDK.Initialize();
if (true == result)
{
// Here, after successful initialization, the game logic
}
else
{
// handle initialization failure here
}
2
3
4
5
6
7
8
9
10
11
You must log in to the stove launcher before calling the
SDK.Initialize
method. Otherwise, initialization will fail.
# How to check when initialization fails
You can check the reason for the error in the log folder (./log) matchmaking_xmpp_date.log file.
# 2) End of matchmaking
it calls after use of matchmaking to clean up resources in use. It deletes the delegate registered for matchmaking and all information entered.
using Stove.PCSDK.NET.Matchmaking;
SDK.Uninitialize();
2
3
# 3) RunCallback
Matchmaking's API is mainly asynchronous to avoid interfering with the game engine and logic.
- After the API call, it loads the result from the matchmaking server into the SDK internal queue.
- Call the RunCallback method when the game wants to process the received result.
- Callbacks loaded in the queue are executed sequentially.
Unity provides a means to call specific methods periodically.
using Stove.PCSDK.NET.Matchmaking;
private FixedUpdate()
{
// Called repeatedly every fixed frame
SDK.RunCallback();
}
2
3
4
5
6
7
# 4) Connect to the matchmaking server
# Server Connection API
Connect to the matchmaking server with the SDK.Connect method.
using Stove.PCSDK.NET.Matchmaking;
// nickname
string nickname = user.Nickname;
SDK.Connect(accessToken, UID, nickname);
2
3
4
5
# Server connection callback
To receive a callback for server connection, you must register a delegate in advance. When the SDK.Connect
method is processed, it calls the nConnect
callback.
// Register the server connection delegate
SDK.EventConnect += GameObj.OnConnect;
private void OnConnect(StovePCMatchmakingError error)
{
// successful connection to matchmaking server
// Process the next game logic, such as moving the scene
if (error.result == StovePCMatchmakingResult.NO_ERROR)
{
GameManager.Instance.LoadModScene();
}
// Failed to connect to matchmaking server
// 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());
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
error.result(error code) can be checked in StovePCMatchmakingResult
. It passes more specific error content to error.message.
# 5) Terminate the connection from the matchmaking server
# Server Connection Termination API
Disconnect from the matchmaking server with the SDK.Disconnect method.
using Stove.PCSDK.NET.Matchmaking;
SDK.Disconnect()
2
3
# Server connection termination callback
To receive a callback for server connection termination, you must register a delegate in advance. When the SDK.Disconnect method is successfully processed. It calls the OnDisconnect callback.
using Stove.PCSDK.NET.Matchmaking;
// Register the server connection termination delegate
SDK.EventDisconnect += GameObj.OnDisconnect;
// Close the matchmaking server connection
private void OnDisconnect(StovePCMatchmakingError error, StovePCMatchmakingDisconnectCode code)
{
switch (code)
{
// When the connection is terminated by calling the Disconnect API
case StovePCMatchmakingDisconnectCode.DISCONNECT_CLIENT:
break;
// Close the client connection from the matchmaking server
case StovePCMatchmakingDisconnectCode.DISCONNECT_SERVER:
break;
// disconnected due to ping timeout (network unstable)
case StovePCMatchmakingDisconnectCode.DISCONNECT_BY_HOST:
break;
// Close connection due to duplicate login
case StovePCMatchmakingDisconnectCode.DISCONNECT_CONFLICT:
break;
}
//Process the following game logic, such as moving the scene
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
code (exit code) can be found in ‘StovePCMatchmakingDisconnectCode’. It passes more specific error content to error.message.
# Additional information
Since it may terminate the connection from the server due to regular maintenance, etc., it is necessary to check the connection termination code. Suppose you log in as the same User in another launcher. In that case, it will terminate the current connection, so appropriate handling is required.
# 6) Entry to the matchmaking lobby
You can participate in the desired lobby when entering the lobby by providing search conditions. It set the search condition with metadata (StovePCMatchmakingMetadata).
# lobby metadata
using Stove.PCSDK.NET.Matchmaking;
// Define the key value of metadata
public struct LOBBY_META_KEY
{
public const string DEFFICULTY_TYPE_KEY = "DefficultyType";
public const string GAMEMODE_TYPE_KEY = "GameModeType";
public const string ROOM_TYPE_KEY = "RoomType";
public const string STAGE_TYPE_KEY = "StageType";
}
// game difficulty
public struct Difficulty
{
public string value; //meta value
public string name; //Name to be displayed in UI
public bool isDefault; // Whether to select the default (if there are multiple, use the first one.)
public string resourcePath; //resource path to display UI
}
// game mode
public struct mode
{
public string value; //meta value
public string name; //Name to be displayed in UI
public
bool isDefault; // Whether to select the default (if there are multiple, use the first one.)
public string resourcePath; //resource path to display UI
public bool isBattleMode; // UI changes depending on whether or not there is a battle mode.
public string[] roomValues; // Room information used in the mod meta value
}
// set the room
public struct room
{
public string value; //meta value
public int maxUser; //Maximum number of people
public string name; //Name to be displayed in UI
public string resourcePath; //resource path to display UI
}
//game stage
public struct stage
{
public string value; //meta value
public string name; //Name to be displayed in UI
public bool isDefault; // Whether to select the default (if there are multiple, use the first one.)
public string resourcePath; //resource path to display UI
}
Defficulty.value = "Beginner";
Mode.value = "Arcade";
Room.value = "Arcade2";
List<StovePCMatchmakingMetadata> metaList = new List<StovePCMatchmakingMetadata>()
{
// set first meta data
// key = "DefficultyType", value = "Beginner"
new StovePCMatchmakingMetadata(LOBBY_META_KEY.DEFFICULTY_TYPE_KEY, Defficulty.value),
// set the second metadata
// key = "GameModType", value = "Arcade"
new StovePCMatchmakingMetadata(LOBBY_META_KEY.GAMEMODE_TYPE_KEY, Mode.value),
// set the third metadata
// key = "RoomType", value = "Arcade2"
new StovePCMatchmakingMetadata(LOBBY_META_KEY.ROOM_TYPE_KEY, Room.value),
};
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Lobby Entry API
Enter the matchmaking lobby with the SDK.JoinRandomLobby
method. You automatically enter one of the lobbies that match your search criteria.
using Stove.PCSDK.NET.Matchmaking;
List<StovePCMatchmakingMetadata> metaList = new List<StovePCMatchmakingMetadata>()
{
// set first meta data
// key = "DefficultyType", value = "Beginner"
new StovePCMatchmakingMetadata(LOBBY_META_KEY.DEFFICULTY_TYPE_KEY, Defficulty.value),
// set the second metadata
// key = "GameModType", value = "Arcade"
new StovePCMatchmakingMetadata(LOBBY_META_KEY.GAMEMODE_TYPE_KEY, Mode.value),
// set the third metadata
// key = "RoomType", value = "Arcade2"
new StovePCMatchmakingMetadata(LOBBY_META_KEY.ROOM_TYPE_KEY, Room.value),
}
// When creating a lobby, the maximum number of users that can enter the lobby
int maxUser = 4;
SDK.JoinRandomLobby(metaList.ToArray(), maxUser);
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
If you find multiple lobbies, you will enter one of the lobbies at random. It is created based on the search criteria if it locates no lobby. When creating a lobby, the User becomes the moderator. You can check the user rating through the StovePCMatchmakingAffiliation
in the OnUserJoin
callback.
# lobby callback
If an error occurs while the SDK.JoinRandomLobby
method is running, you can check the contents in error.result (error code) StovePCMatchmakingResult
.
To receive multiple callbacks to the lobby, you must register a delegate in advance.
- When you enter the lobby,
OnJoinLobby
=> (OnUserJoin
* number of users including yourself) is called consecutively. - Whenever another user enters the lobby, the
OnUserJoin
callback is called. ** You can check user rating throughStovePCMatchmakingAffiliation
in theOnUserJoin
callback. - Whenever another user leaves the lobby, the
OnUserLeave
callback is called. - When leaving the lobby, the
OnLeaveLobby
callback is called. ** In addition to API calls, it also calls when it forces you to leave due to lobby kick/ban, lobby deletion, etc. - When the moderator leaves, it transfers the moderator to the entry order and calls the
OnUserUpdate
callback. ** In theOnUserUpdate
callback, you can check the User's information who it has transferred.
using Stove.PCSDK.NET.Matchmaking;
// lobby related delegate
// Register lobby entry delegate
SDK.EventJoinLobby += GameObj.OnJoinLobby;
// Register the user entry delegate in the lobby
SDK.EventUserJoin += GameObj.OnUserJoin;
// Register the user information update delegate in the lobby
SDK.EventUserUpdate += GameObj.OnUserUpdate;
// Register the user exit delegate in the lobby
SDK.EventUserLeave += GameObj.OnUserLeave;
// Register lobby exit delegate
SDK.EventLeaveLobby += GameObj.OnLeaveLobby;
// Enter the matchmaking lobby
private void OnJoinLobby(StovePCMatchmakingError error, StovePCMatchmakingJoinLobby joinLobby)
{
// Process the next game logic, such as moving the scene
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());
}
}
//User enters the lobby (including myself)
private void OnUserJoin(StovePCMatchmakingError error, StovePCMatchmakingUserJoin userJoin)
{
StringBuilder sb = new StringBuilder();
// Unique Lobby ID
sb.AppendFormat("lobby = {0}", userJoin.lobby);
// user ID
sb.AppendFormat("userID = {0}", userJoin.UID);
// user nickname
sb.AppendFormat("userNickname = {0}", nickname);
// User rating in the lobby ( 0 = Normal, 4 = Moderator )
sb.AppendFormat("affiliation = {0}", userJoin.affiliation);
// User metadata, storage space of the user in the lobby
foreach(var data in userJoin.userDataArray)
{
sb.AppendFormat("meta {0} = {1}", data.key, data.value);
}
Debug.Log(sb.ToString());
//Process game logic
}
// Update user information (including me) in the lobby
private void OnUserUpdate(StovePCMatchmakingError error, StovePCMatchmakingUpdateLobbyUser userUpdate)
{
StringBuilder sb = new StringBuilder();
// Unique Lobby ID
sb.AppendFormat("lobby = {0}", userUpdate.lobby);
// user ID
sb.AppendFormat("userID = {0}", userUpdate.UID);
// user nickname
sb.AppendFormat("userNickname = {0}", userUpdate.nickname);
// User rating in the lobby ( 0 = Normal, 4 = Moderator )
sb.AppendFormat("affiliation = {0}", userUpdate.affiliation);
// User metadata, storage space of the user in the lobby
foreach(var data in userUpdate.userDataArray)
{
sb.Appe
ndFormat("meta {0} = {1}", data.key, data.value);
}
Debug.Log(sb.ToString());
//Process game logic
}
// Exit another user from the lobby
private void OnUserLeave(StovePCMatchmakingError error, StovePCMatchmakingUserLeave userLeave)
{
StringBuilder sb = new StringBuilder();
// Unique Lobby ID
sb.AppendFormat("lobby = {0}", userLeave.lobby);
// user ID
sb.AppendFormat("userID = {0}", userLeave.userID);
// user nickname
sb.AppendFormat("userNickname = {0}", userLeave.nickname);
// Reason code for user leaving (You can check the contents in `StovePCMatchmakingResult`)
sb.AppendFormat("leaveCode = {0}", error.result);
Debug.Log(sb.ToString());
//reason for leaving the lobby of other users
switch(error.result)
{
// Leave the lobby by calling the API
case StovePCMatchmakingResult.NO_ERROR:
break;
// the manager kicks
case StovePCMatchmakingResult.USER_KICKED:
break;
// moderator van
case StovePCMatchmakingResult.USER_BANNED:
break;
// Moderator deletes lobby
case StovePCMatchmakingResult.USER_ROOM_DESTROYED:
break;
// Remove lobby from server
case StovePCMatchmakingResult.USER_ROOM_SHUTDOWN:
break;
// Remove lobby due to operational issue
case StovePCMatchmakingResult.ROOM_DELETED_AS_OPERATIONAL:
break;
}
//Process game logic
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
The lobby ID is unique to the lobby. You can use it when calling other lobby-related APIs.
In the lobby, you must call the RunCallback method periodically because other users can enter, update information, or receive messages.
# 7) Exit the matchmaking lobby
# Lobby Exit API
Leave the matchmaking lobby with the SDK.LeaveLobby
method.
using Stove.PCSDK.NET.Matchmaking;
string lobby = this.lobby;
SDK.LeaveLobby(lobby);
2
3
4
# lobby callback
If an error occurs while the SDK.LeaveLobby
method is running, you can check the contents in error.result (error code) StovePCMatchmakingResult
.
To receive a callback about leaving the lobby, you must register a delegate in advance.
It calls the OnLeaveLobby
callback when I leave the lobby.
It is also called back when it forces you to leave the lobby due to lobby kick/ban by the host or lobby deletion.
For other users, it calls the OnUserLeave
callback.
using Stove.PCSDK.NET.Matchmaking;
// Register lobby exit delegate
SDK.EventLeaveLobby += GameObj.OnLeaveLobby;
// Leave the lobby
private void OnLeaveLobby(StovePCMatchmakingError error, StovePCMatchmakingLeaveLobby leaveLobby)
{
StringBuilder sb = new StringBuilder();
// Unique Lobby ID
sb.AppendFormat("lobby = {0}", lobby);
// Reason code for user leaving (You can check the contents in `StovePCMatchmakingResult`)
sb.AppendFormat("leaveCode = {0}", error.result);
Debug.Log(sb.ToString());
// Reason for leaving the lobby
switch(error.result)
{
// Leave the lobby by calling the API
case StovePCMatchmakingResult.NO_ERROR:
break;
// the manager kicks
case StovePCMatchmakingResult.USER_KICKED:
break;
// moderator van
case StovePCMatchmakingResult.USER_BANNED:
break;
// Moderator deletes lobby
case StovePCMatchmakingResult.USER_ROOM_DESTROYED:
break;
// Remove lobby from server
case StovePCMatchmakingResult.USER_ROOM_SHUTDOWN:
break;
// Remove lobby due to operational issue
case StovePCMatchmakingResult.ROOM_DELETED_AS_OPERATIONAL:
break;
}
//Process game logic
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
You can check the contents of StovePCMatchmakingResult
through error.result if it has kicked off you.
# 8) Send and receive matchmaking lobby chat messages
# 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);
2
3
4
5
6
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());
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
You should call the RunCallback method periodically because the lobby may receive other user messages.
# 9) Send and 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);
2
3
4
5
6
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());
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
You should call the RunCallback method periodically because the lobby can receive other user data.
# 10) Start Matchmaking Lobby Game
# Lobby Game Start API
The SDK.StartGame
method notifies the matchmaking server and all users that the lobby is about to start a game.
using Stove.PCSDK.NET.Matchmaking;
string lobby = this.lobby;
SDK.StartGame(lobby, "", 0);
2
3
4
Only the moderator can call. When a user other than the moderator calls it, it calls back an error. In Server IP and Port, enter the address of the game server to be linked in the client. If there is no game server to be connected, enter an empty value. You cannot enter the lobby after the game has started.
# Lobby game start callback
If an error occurs while the SDK.StartGame
method is running, you can check the contents in error.result (error code) StovePCMatchmakingResult
.
To receive a callback for starting a lobby game, you must register a delegate in advance. It calls the StartGame
callback for all users in the lobby.
using Stove.PCSDK.NET.Matchmaking;
// Register the lobby game start delegate
SDK.EventStartGame += GameObj.OnStartGame;
// start lobby game
private void OnStartGame(StovePCMatchmakingError error, StovePCMatchmakingStartGame startGame)
{
// Process game logic such as moving scenes
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());
}
}
> You should periodically call the RunCallback method because the lobby can receive notification of the start of the game.
### 11) End matchmaking lobby game
#### Lobby Game Closing API
The `SDK.EndGame` method notifies the matchmaking server and all users that the lobby ends the game.
``` cs
using Stove.PCSDK.NET.Matchmaking;
string lobby = this.lobby;
SDK.EndGame(lobby, "", 0);
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Only the moderator can call. When a user other than the moderator calls it, it calls back an error. In Server IP and Port, enter the address of the game server to be linked in the client. If there is no game server to be connected, enter an empty value. After the game is over, it automatically deletes the lobby.
# Lobby game end callback
If an error occurs while the SDK.EndGame
method is running, you can check the contents in error.result (error code) StovePCMatchmakingResult
.
To receive a callback for the end of the lobby game, you must register a delegate in advance.
- The
EndGame
callback is called for all users in the lobby. - All users in the lobby will call the
OnLeaveLobby
callback.
using Stove.PCSDK.NET.Matchmaking;
// Register the lobby game start delegate
SDK.EventEndGame += GameObj.OnEndGame;
// end the lobby game
private void OnEndGame(StovePCMatchmakingError error, StovePCMatchmakingEndGame endGame)
{
// Process game logic such as moving scenes
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());
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
You should periodically call the RunCallback method because the lobby can receive game end notifications.