StovePCMatchmaking(Native dll)  1.0.4.1
stove_pc_matchmaking_sample.h
1 
4 #include <iostream>
5 
8 #include "MetadataHelper.h"
9 
10 #include <string>
11 #include <vector>
12 #include <codecvt>
13 
14 extern std::wstring myLobby;
15 
16 // Server connection callbacks
17 void OnConnect(const StovePCMatchmakingError error)
18 {
20  std::wcout << L"- Success" << std::endl;
21  else
22  std::wcout << L"- failed, code = " << error.result << std::endl;
23 }
24 
25 // Server connection termination callback
26 void OnDisconnect(const StovePCMatchmakingError error, const StovePCMatchmakingDisconnectCode code)
27 {
28  // Connection termination code ( See also ::StovePCMatchmakingDisconnectCode)
29  std::wcout << L"- Disconnect code = " << code << std::endl;
30 }
31 
32 // Lobby creation callback
33 void OnCreateLobby(const StovePCMatchmakingError error, const StovePCMatchmakingCreateLobby createLobby)
34 {
36  std::wcout << L"- Success" << std::endl;
37  else
38  std::wcout << L"- failed, code = " << error.result << std::endl;
39 
40  // Lobby ID you created
41  std::wcout << L"- Create Lobby = " << createLobby.lobby << std::endl;
42 }
43 
44  // Lobby entry callbacks
45 void OnJoinLobby(const StovePCMatchmakingError error, const StovePCMatchmakingJoinLobby joinLobby)
46 {
48  std::wcout << L"- Success" << std::endl;
49  else
50  std::wcout << L"- failed, code = " << error.result << std::endl;
51 
52  // Name of the lobby you entered
53  std::wcout << L"- Join Lobby = " << joinLobby.lobby << std::endl;
54  std::wcout << "== config ==";
55  MetadataHelper config(joinLobby.lobbyDataArray, joinLobby.lobbyDataCount); // Convert a lobby data array to a map
56  for (auto pair : config)
57  {
58  std::wcout << pair.first << " : " << pair.second << std::endl;
59  }
60 
61  myLobby = joinLobby.lobby;
62 }
63 
64 // Lobby settings update callback
65 void OnUpdateLobbyData(const StovePCMatchmakingError error, const StovePCMatchmakingUpdateLobbyData updateLobbyData)
66 {
67  std::wcout << L"update lobby = " << updateLobbyData.lobby // 로비명
68  << std::endl;
69 
70  std::wcout << "== config ==";
71  MetadataHelper config(updateLobbyData.lobbyDataArray, updateLobbyData.lobbyDataCount); // Convert a lobby data array to a map
72  for (auto pair : config)
73  {
74  std::wcout << pair.first << " : " << pair.second << std::endl;
75  }
76 }
77 
78 // Lobby exit callback
79 void OnLeaveLobby(const StovePCMatchmakingError error, const StovePCMatchmakingLeaveLobby leaveLobby)
80 {
81  std::wcout << L"- Leave Lobby = " << leaveLobby.lobby << std::endl;
82 
83  // Exit code (see ::StovePCMatchmakingResult)
84  std::wcout << L"leave lobby code = " << error.result << std::endl;
85 }
86 
87 // Lobby user entry callback
88 void OnUserJoin(const StovePCMatchmakingError error, const StovePCMatchmakingUserJoin userJoin)
89 {
90  // Name of the lobby you entered
91  std::wcout << L"user join lobby = " << userJoin.lobby
92  << L"UID = " << userJoin.UID // Entered username
93  << L"nickname = " << userJoin.nickname // Entered user nickname
94  << L"affiliation = " << userJoin.affiliation // Entered user rating
95  << std::endl;
96 
97  std::wcout << "== user data ==";
98  MetadataHelper config(userJoin.userDataArray, userJoin.userDataCount); // Convert an array of user data to a map
99  for (auto pair : config)
100  {
101  std::wcout << pair.first << " : " << pair.second << std::endl;
102  }
103 }
104 
105 // Lobby User State Value Update Callback
106 void OnUpdateLobbyUser(const StovePCMatchmakingError error, const StovePCMatchmakingUpdateLobbyUser updateLobbyUser)
107 {
108  std::wcout << L"update user lobby = " << updateLobbyUser.lobby // Lobby Name
109  << L"UID = " << updateLobbyUser.UID // User ID
110  << L"nickname = " << updateLobbyUser.nickname // Entered user nickname
111  << L"affiliation = " << updateLobbyUser.affiliation // User ratings
112  << std::endl;
113 
114  std::wcout << "== user data ==";
115  MetadataHelper config(updateLobbyUser.userDataArray, updateLobbyUser.userDataCount); // Convert an array of user data to a map
116  for (auto pair : config)
117  {
118  std::wcout << pair.first << " : " << pair.second << std::endl;
119  }
120 }
121 
122 // Lobby user exit callback
123 void OnUserLeave(const StovePCMatchmakingError error, const StovePCMatchmakingUserLeave userLeave)
124 {
125  std::wcout << L"user leave lobby = " << userLeave.lobby // Exited lobby name
126  << L"UID = " << userLeave.UID // Exited User ID
127  << L"nickname = " << userLeave.nickname // Exited user nickname
128  << L"leave code = " << error.result // Exit code (see ::StovePCMatchmakingResult)
129  << std::endl;
130 }
int lobbyDataCount
Number of lobby metadata arrays
Definition: StovePCMatchmakingCallback.h:225
unsigned __int64 UID
ID
Definition: StovePCMatchmakingCallback.h:133
const wchar_t * nickname
User Nickname
Definition: StovePCMatchmakingCallback.h:136
int lobbyDataCount
Number of lobby metadata arrays
Definition: StovePCMatchmakingCallback.h:120
const wchar_t * lobby
Lobby Name
Definition: StovePCMatchmakingCallback.h:175
StovePCMatchmakingResult result
콜Resulting response to a hundred
Definition: StovePCMatchmakingCallback.h:26
int userDataCount
Number of user data arrays
Definition: StovePCMatchmakingCallback.h:206
const StovePCMatchmakingMetadata * lobbyDataArray
Lobby metadata array pointer (ex. StovePCMatchmakingMetadata [] array)
Definition: StovePCMatchmakingCallback.h:117
StovePCMatchmakingCallback 헤더파일
StovePCMatchmakingAffiliation affiliation
Ratings in the lobby
Definition: StovePCMatchmakingCallback.h:200
StovePCMatchmakingDisconnectCode
Connection termination response value
Definition: StovePCMatchmakingDefine.h:252
로비 메타 데이터가 업데이트될시 응답값입니다.
Definition: StovePCMatchmakingCallback.h:216
Normal
Definition: StovePCMatchmakingDefine.h:18
Definition: MetadataHelper.h:11
unsigned __int64 UID
ID
Definition: StovePCMatchmakingCallback.h:194
const wchar_t * lobby
Lobby Name
Definition: StovePCMatchmakingCallback.h:191
로비를 만든 후 응답 값입니다. 로비 생성을 알립니다.
Definition: StovePCMatchmakingCallback.h:92
StovePCMatchmakingAffiliation affiliation
Ratings in the lobby
Definition: StovePCMatchmakingCallback.h:139
const wchar_t * nickname
User Nickname
Definition: StovePCMatchmakingCallback.h:197
const wchar_t * lobby
Name of the lobby you entered
Definition: StovePCMatchmakingCallback.h:108
const wchar_t * lobby
Lobby Name
Definition: StovePCMatchmakingCallback.h:219
const StovePCMatchmakingMetadata * userDataArray
로비 내 해당 유저의 메타 데이터 배열 포인터 (ex. StovePCMatchmakingMetadata [] array) ...
Definition: StovePCMatchmakingCallback.h:203
const wchar_t * nickname
User Nickname
Definition: StovePCMatchmakingCallback.h:181
로비 참여 유저에 대한 응답값입니다. 로비에 유저가 입장시 호출됩니다.
Definition: StovePCMatchmakingCallback.h:127
unsigned __int64 UID
Exit user ID
Definition: StovePCMatchmakingCallback.h:178
StovePCMatchmakingDefine 헤더파일
const wchar_t * lobby
Name of the created lobby
Definition: StovePCMatchmakingCallback.h:95
const wchar_t * lobby
Lobby Name
Definition: StovePCMatchmakingCallback.h:155
int userDataCount
Number of user data arrays
Definition: StovePCMatchmakingCallback.h:145
const StovePCMatchmakingMetadata * userDataArray
Pointer to the metadata array for that user in the lobby (ex. StovePCMatchmakingMetadata [] array) ...
Definition: StovePCMatchmakingCallback.h:142
The updated response value of the lobby user. Called when user information or user data changes in the lobby.
Definition: StovePCMatchmakingCallback.h:188
The response to leaving the lobby. Called when the user exits the lobby.
Definition: StovePCMatchmakingCallback.h:152
Response to a user leaving the lobby. Called when a user exits the lobby.
Definition: StovePCMatchmakingCallback.h:172
The response value for the lobby position. Notifies the lobby position.
Definition: StovePCMatchmakingCallback.h:102
The structure passed to the callback when it is called.
Definition: StovePCMatchmakingCallback.h:20
const StovePCMatchmakingMetadata * lobbyDataArray
로비 메타 데이터 배열 포인터 (ex. StovePCMatchmakingMetadata [] array)
Definition: StovePCMatchmakingCallback.h:222
const wchar_t * lobby
Lobby Name
Definition: StovePCMatchmakingCallback.h:130