dfx 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DiscordREST/types.js +6 -0
- package/DiscordREST/types.js.map +1 -0
- package/DiscordWS/index.js +2 -0
- package/DiscordWS/index.js.map +1 -0
- package/README.md +3 -0
- package/WS/index.js +71 -0
- package/WS/index.js.map +1 -0
- package/discord-api-docs/index.js +1 -0
- package/mod.js.map +1 -0
- package/package.json +6 -1
- package/types.js +1563 -0
- package/types.js.map +1 -0
- package/websocket.js +11 -0
- package/websocket.js.map +1 -0
- package/.gitmodules +0 -3
- package/.prettierrc.json +0 -4
- package/discord-api-docs/.eslintrc.json +0 -10
- package/discord-api-docs/.gitattributes +0 -11
- package/discord-api-docs/.github/ISSUE_TEMPLATE/api-bug-report.yml +0 -49
- package/discord-api-docs/.github/ISSUE_TEMPLATE/config.yml +0 -20
- package/discord-api-docs/.github/ISSUE_TEMPLATE/developer-site-bug-report.yml +0 -49
- package/discord-api-docs/.github/ISSUE_TEMPLATE/message-components-bug-report.yml +0 -49
- package/discord-api-docs/.github/ISSUE_TEMPLATE/slash-command-bug-report.yml +0 -49
- package/discord-api-docs/.github/workflows/test.yaml +0 -45
- package/discord-api-docs/.prettierignore +0 -1
- package/discord-api-docs/.prettierrc.json +0 -15
- package/discord-api-docs/CODE_OF_CONDUCT.md +0 -75
- package/discord-api-docs/CONTRIBUTING.md +0 -16
- package/discord-api-docs/README.md +0 -35
- package/discord-api-docs/docs/Change_Log.md +0 -474
- package/discord-api-docs/docs/Intro.md +0 -48
- package/discord-api-docs/docs/Legal.md +0 -154
- package/discord-api-docs/docs/Policy.md +0 -81
- package/discord-api-docs/docs/Reference.md +0 -476
- package/discord-api-docs/docs/Store_Distribution_Agreement.md +0 -179
- package/discord-api-docs/docs/dispatch/Branches_and_Builds.md +0 -654
- package/discord-api-docs/docs/dispatch/Dispatch_and_You.md +0 -17
- package/discord-api-docs/docs/dispatch/Error_Codes.md +0 -26
- package/discord-api-docs/docs/dispatch/Field_Values.md +0 -48
- package/discord-api-docs/docs/dispatch/List_of_Commands.md +0 -315
- package/discord-api-docs/docs/game_and_server_management/Alpha_and_Beta_Testing.md +0 -52
- package/discord-api-docs/docs/game_and_server_management/How_to_Get_Your_Game_on_Discord.md +0 -110
- package/discord-api-docs/docs/game_and_server_management/Special_Channels.md +0 -38
- package/discord-api-docs/docs/game_sdk/Achievements.md +0 -405
- package/discord-api-docs/docs/game_sdk/Activities.md +0 -561
- package/discord-api-docs/docs/game_sdk/Applications.md +0 -237
- package/discord-api-docs/docs/game_sdk/Discord.md +0 -443
- package/discord-api-docs/docs/game_sdk/Discord_Voice.md +0 -289
- package/discord-api-docs/docs/game_sdk/Images.md +0 -196
- package/discord-api-docs/docs/game_sdk/Lobbies.md +0 -1639
- package/discord-api-docs/docs/game_sdk/Networking.md +0 -377
- package/discord-api-docs/docs/game_sdk/Overlay.md +0 -195
- package/discord-api-docs/docs/game_sdk/Relationships.md +0 -234
- package/discord-api-docs/docs/game_sdk/SDK_Starter_Guide.md +0 -310
- package/discord-api-docs/docs/game_sdk/Storage.md +0 -312
- package/discord-api-docs/docs/game_sdk/Store.md +0 -555
- package/discord-api-docs/docs/game_sdk/Users.md +0 -178
- package/discord-api-docs/docs/interactions/Application_Commands.md +0 -1069
- package/discord-api-docs/docs/interactions/Message_Components.md +0 -454
- package/discord-api-docs/docs/interactions/Receiving_and_Responding.md +0 -372
- package/discord-api-docs/docs/interactions/Slash_Commands.md +0 -3
- package/discord-api-docs/docs/resources/Application.md +0 -82
- package/discord-api-docs/docs/resources/Audit_Log.md +0 -223
- package/discord-api-docs/docs/resources/Channel.md +0 -1267
- package/discord-api-docs/docs/resources/Emoji.md +0 -122
- package/discord-api-docs/docs/resources/Guild.md +0 -1157
- package/discord-api-docs/docs/resources/Guild_Scheduled_Event.md +0 -273
- package/discord-api-docs/docs/resources/Guild_Template.md +0 -148
- package/discord-api-docs/docs/resources/Invite.md +0 -150
- package/discord-api-docs/docs/resources/Stage_Instance.md +0 -106
- package/discord-api-docs/docs/resources/Sticker.md +0 -164
- package/discord-api-docs/docs/resources/User.md +0 -205
- package/discord-api-docs/docs/resources/Voice.md +0 -55
- package/discord-api-docs/docs/resources/Webhook.md +0 -281
- package/discord-api-docs/docs/rich_presence/Best_Practices.md +0 -88
- package/discord-api-docs/docs/rich_presence/FAQ.md +0 -45
- package/discord-api-docs/docs/rich_presence/How_To.md +0 -302
- package/discord-api-docs/docs/rich_presence/Launch_Checklist.md +0 -46
- package/discord-api-docs/docs/topics/Certified_Devices.md +0 -200
- package/discord-api-docs/docs/topics/Community_Resources.md +0 -98
- package/discord-api-docs/docs/topics/Gateway.md +0 -1600
- package/discord-api-docs/docs/topics/OAuth2.md +0 -427
- package/discord-api-docs/docs/topics/Opcodes_and_Status_Codes.md +0 -306
- package/discord-api-docs/docs/topics/Permissions.md +0 -229
- package/discord-api-docs/docs/topics/RPC.md +0 -1597
- package/discord-api-docs/docs/topics/Rate_Limits.md +0 -126
- package/discord-api-docs/docs/topics/Teams.md +0 -80
- package/discord-api-docs/docs/topics/Threads.md +0 -163
- package/discord-api-docs/docs/topics/Voice_Connections.md +0 -282
- package/discord-api-docs/images/API_center.gif +0 -0
- package/discord-api-docs/images/ask-to-join.gif +0 -0
- package/discord-api-docs/images/available-published.png +0 -0
- package/discord-api-docs/images/button-styles.png +0 -0
- package/discord-api-docs/images/certified-device.png +0 -0
- package/discord-api-docs/images/command-with-groups-subcommands-parameters.png +0 -0
- package/discord-api-docs/images/command-with-groups-subcommands.png +0 -0
- package/discord-api-docs/images/command.png +0 -0
- package/discord-api-docs/images/cpp-files-sdk.png +0 -0
- package/discord-api-docs/images/create-store-channel.png +0 -0
- package/discord-api-docs/images/deferred-example.png +0 -0
- package/discord-api-docs/images/desktop-select.png +0 -0
- package/discord-api-docs/images/game-overlay-sdk-invite.gif +0 -0
- package/discord-api-docs/images/game-overlay-sdk-voice-settings.png +0 -0
- package/discord-api-docs/images/game-overlay-sdk-voice-widget.png +0 -0
- package/discord-api-docs/images/gift-code-creation.png +0 -0
- package/discord-api-docs/images/lib-linked-sdk.png +0 -0
- package/discord-api-docs/images/message-command.png +0 -0
- package/discord-api-docs/images/mobile-select.png +0 -0
- package/discord-api-docs/images/previous-new-server-background.png +0 -0
- package/discord-api-docs/images/rp-actionable.png +0 -0
- package/discord-api-docs/images/rp-all-fields.png +0 -0
- package/discord-api-docs/images/rp-bad-art.png +0 -0
- package/discord-api-docs/images/rp-good-art.png +0 -0
- package/discord-api-docs/images/rp-legend.png +0 -0
- package/discord-api-docs/images/rp-long-strings.png +0 -0
- package/discord-api-docs/images/rp-non-actionable.png +0 -0
- package/discord-api-docs/images/rp-not-all-fields.png +0 -0
- package/discord-api-docs/images/rp-profile-example-1.png +0 -0
- package/discord-api-docs/images/rp-profile-example-2.png +0 -0
- package/discord-api-docs/images/rp-short-strings.png +0 -0
- package/discord-api-docs/images/server-banner-example.png +0 -0
- package/discord-api-docs/images/server-banner-margin-top.png +0 -0
- package/discord-api-docs/images/sku-management.png +0 -0
- package/discord-api-docs/images/snowflake.png +0 -0
- package/discord-api-docs/images/snowflake_original_size.png +0 -0
- package/discord-api-docs/images/spectate.gif +0 -0
- package/discord-api-docs/images/team-2fa.png +0 -0
- package/discord-api-docs/images/team-make-app.png +0 -0
- package/discord-api-docs/images/team-page.png +0 -0
- package/discord-api-docs/images/transfer-app-to-team.png +0 -0
- package/discord-api-docs/images/user-command.png +0 -0
- package/discord-api-docs/package-lock.json +0 -3186
- package/discord-api-docs/package.json +0 -38
- package/discord-api-docs/tsconfig.eslint.json +0 -4
- package/discord-api-docs/tsconfig.json +0 -19
- package/tsconfig.json +0 -24
|
@@ -1,1639 +0,0 @@
|
|
|
1
|
-
# Lobbies
|
|
2
|
-
|
|
3
|
-
> info
|
|
4
|
-
> Need help with the SDK? Talk to us in the [Discord Developers Server](https://discord.gg/discord-developers)!
|
|
5
|
-
|
|
6
|
-
> danger
|
|
7
|
-
> Selling SKUs on Discord is now deprecated, and will be discontinued on March 1, 2022. [Read here for more info.](https://support-dev.discord.com/hc/en-us/articles/4414590563479)
|
|
8
|
-
|
|
9
|
-
Looking to integrate multiplayer into your game? Lobbies are a great way to organize players into contexts to play together. This manager works hand in hand with the networking layer of our SDK to make multiplayer integrations a breeze by:
|
|
10
|
-
|
|
11
|
-
- Creating, managing, and joining lobbies
|
|
12
|
-
- Matchmaking users based on lobby metadata, like ELO
|
|
13
|
-
- Getting and setting arbitrary metadata on lobbies and lobby members
|
|
14
|
-
|
|
15
|
-
Lobbies in Discord work in one of two ways. By using calls from the SDK, lobbies are effectively "owned" by the user who's client creates the lobby. Someone boots up the game, hits your "Create Lobby" button, and their game client calls `LobbyManager.CreateLobby()` from the Discord SDK.
|
|
16
|
-
|
|
17
|
-
There is also another way to create and "own" lobbies with which the source of truth can be your own server. These SDK functions calls map to API endpoints that are exposed in Discord's HTTP API. In lieu of creating and managing lobbies in the SDK, you can call those endpoints directly with a token for your application and take care of it all on some far-away, totally secure server. Let's go over the SDK first.
|
|
18
|
-
|
|
19
|
-
## The SDK Way
|
|
20
|
-
|
|
21
|
-
In order to ensure that Discord lobbies are consistent for all players, this manager works with "transactions". A `LobbyTransaction` is needed to set lobby properties, like capacity. A `MemberTransaction` is needed to set lobby member properties, like metadata.
|
|
22
|
-
|
|
23
|
-
To update a user or a lobby, create or get a transaction for that resource, call the needed methods on it, and then pass it to the `Create()` or `Update()` methods. When passed to a `Create()` or `Update()` method, the transaction objected is consumed. So, if you want to do another `Create()` or `Update()`, you need to get a new transaction.
|
|
24
|
-
|
|
25
|
-
###### Example: Creating a Lobby
|
|
26
|
-
|
|
27
|
-
```cs
|
|
28
|
-
var lobbyManager = discord.GetLobbyManager();
|
|
29
|
-
|
|
30
|
-
// Create the transaction
|
|
31
|
-
var txn = lobbyManager.GetLobbyCreateTransaction();
|
|
32
|
-
|
|
33
|
-
// Set lobby information
|
|
34
|
-
txn.SetCapacity(6);
|
|
35
|
-
txn.SetType(Discord.LobbyType.Public);
|
|
36
|
-
txn.SetMetadata("a", "123");
|
|
37
|
-
|
|
38
|
-
// Create it!
|
|
39
|
-
lobbyManager.CreateLobby(txn, (Discord.Result result, ref Discord.Lobby lobby) =>
|
|
40
|
-
{
|
|
41
|
-
Console.WriteLine("lobby {0} created with secret {1}", lobby.Id, lobby.Secret);
|
|
42
|
-
|
|
43
|
-
// We want to update the capacity of the lobby
|
|
44
|
-
// So we get a new transaction for the lobby
|
|
45
|
-
var newTxn = lobbyManager.GetLobbyUpdateTransaction(lobby.id);
|
|
46
|
-
newTxn.SetCapacity(5);
|
|
47
|
-
|
|
48
|
-
lobbyManager.UpdateLobby(lobby.id, newTxn, (result) =>
|
|
49
|
-
{
|
|
50
|
-
Console.WriteLine("lobby {0} updated", lobby.Id);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Data Models
|
|
56
|
-
|
|
57
|
-
###### LobbyType Enum
|
|
58
|
-
|
|
59
|
-
| name | value |
|
|
60
|
-
| ------- | ----- |
|
|
61
|
-
| Private | 1 |
|
|
62
|
-
| Public | 2 |
|
|
63
|
-
|
|
64
|
-
###### Lobby Struct
|
|
65
|
-
|
|
66
|
-
| name | type | description |
|
|
67
|
-
| -------- | --------- | -------------------------------------- |
|
|
68
|
-
| Id | Int64 | the unique id of the lobby |
|
|
69
|
-
| Type | LobbyType | if the lobby is public or private |
|
|
70
|
-
| OwnerId | Int64 | the userId of the lobby owner |
|
|
71
|
-
| Secret | string | the password to the lobby |
|
|
72
|
-
| Capacity | UInt32 | the max capacity of the lobby |
|
|
73
|
-
| Locked | bool | whether or not the lobby can be joined |
|
|
74
|
-
|
|
75
|
-
###### LobbySearchComparison Enum
|
|
76
|
-
|
|
77
|
-
| name | value |
|
|
78
|
-
| ------------------ | ----- |
|
|
79
|
-
| LessThanOrEqual | -2 |
|
|
80
|
-
| LessThan | -1 |
|
|
81
|
-
| Equal | 0 |
|
|
82
|
-
| GreaterThan | 1 |
|
|
83
|
-
| GreaterThanOrEqual | 2 |
|
|
84
|
-
| NotEqual | 3 |
|
|
85
|
-
|
|
86
|
-
###### LobbySearchCast Enum
|
|
87
|
-
|
|
88
|
-
| name | value |
|
|
89
|
-
| ------ | ----- |
|
|
90
|
-
| String | 1 |
|
|
91
|
-
| Number | 2 |
|
|
92
|
-
|
|
93
|
-
###### LobbySearchDistance Enum
|
|
94
|
-
|
|
95
|
-
| name | value | description |
|
|
96
|
-
| -------- | ----- | ------------------------------------ |
|
|
97
|
-
| Local | 0 | within the same region |
|
|
98
|
-
| Default | 1 | within the same and adjacent regions |
|
|
99
|
-
| Extended | 2 | far distances, like US to EU |
|
|
100
|
-
| Global | 3 | all regions |
|
|
101
|
-
|
|
102
|
-
###### LobbyTransaction Struct
|
|
103
|
-
|
|
104
|
-
Has no values, but has member functions, outlined later.
|
|
105
|
-
|
|
106
|
-
###### LobbyMemberTransaction Struct
|
|
107
|
-
|
|
108
|
-
Has no values, but has member functions, outlined later.
|
|
109
|
-
|
|
110
|
-
###### LobbySearchQuery Struct
|
|
111
|
-
|
|
112
|
-
Has no values, but has member functions, outlined later.
|
|
113
|
-
|
|
114
|
-
## LobbyTransaction.SetType
|
|
115
|
-
|
|
116
|
-
Marks a lobby as private or public.
|
|
117
|
-
|
|
118
|
-
Returns `void`.
|
|
119
|
-
|
|
120
|
-
###### Parameters
|
|
121
|
-
|
|
122
|
-
| name | type | description |
|
|
123
|
-
| ---- | --------- | ----------------- |
|
|
124
|
-
| type | LobbyType | private or public |
|
|
125
|
-
|
|
126
|
-
###### Example
|
|
127
|
-
|
|
128
|
-
```cs
|
|
129
|
-
var txn = lobbyManager.GetLobbyUpdateTransaction();
|
|
130
|
-
txn.SetType(Discord.LobbyType.Public);
|
|
131
|
-
lobbyManager.UpdateLobby(lobbyId, txn, (Discord.Result result) =>
|
|
132
|
-
{
|
|
133
|
-
if (result == Discord.Result.Ok)
|
|
134
|
-
{
|
|
135
|
-
Console.WriteLine("Lobby type updated!");
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
## LobbyTransaction.SetOwner
|
|
141
|
-
|
|
142
|
-
> warn
|
|
143
|
-
> This method is only valid for `LobbyUpdateTransactions` and may cause issues if you set it on a `LobbyCreateTransaction`.
|
|
144
|
-
|
|
145
|
-
Sets a new owner for the lobby.
|
|
146
|
-
|
|
147
|
-
Returns `void`.
|
|
148
|
-
|
|
149
|
-
###### Parameters
|
|
150
|
-
|
|
151
|
-
| name | type | description |
|
|
152
|
-
| ------ | ----- | ----------------------- |
|
|
153
|
-
| userId | Int64 | the new owner's user id |
|
|
154
|
-
|
|
155
|
-
###### Example
|
|
156
|
-
|
|
157
|
-
```cs
|
|
158
|
-
var txn = lobbyManager.GetLobbyUpdateTransaction();
|
|
159
|
-
txn.SetOwner(53908232506183680);
|
|
160
|
-
lobbyManager.UpdateLobby(lobbyId, txn, (Discord.Result result) =>
|
|
161
|
-
{
|
|
162
|
-
if (result == Discord.Result.Ok)
|
|
163
|
-
{
|
|
164
|
-
Console.WriteLine("Lobby owner updated!");
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
## LobbyTransaction.SetCapacity
|
|
170
|
-
|
|
171
|
-
Sets a new capacity for the lobby.
|
|
172
|
-
|
|
173
|
-
Returns `void`.
|
|
174
|
-
|
|
175
|
-
###### Parameters
|
|
176
|
-
|
|
177
|
-
| name | type | description |
|
|
178
|
-
| -------- | ------ | ---------------------- |
|
|
179
|
-
| capacity | UInt32 | the new max lobby size |
|
|
180
|
-
|
|
181
|
-
###### Example
|
|
182
|
-
|
|
183
|
-
```cs
|
|
184
|
-
var txn = lobbyManager.GetLobbyUpdateTransaction();
|
|
185
|
-
txn.SetCapacity(10);
|
|
186
|
-
lobbyManager.UpdateLobby(lobbyId, txn, (Discord.Result result) =>
|
|
187
|
-
{
|
|
188
|
-
if (result == Discord.Result.Ok)
|
|
189
|
-
{
|
|
190
|
-
Console.WriteLine("Lobby capacity updated!");
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
## LobbyTransaction.SetMetadata
|
|
196
|
-
|
|
197
|
-
Sets metadata value under a given key name for the lobby.
|
|
198
|
-
|
|
199
|
-
Returns `void`.
|
|
200
|
-
|
|
201
|
-
###### Parameters
|
|
202
|
-
|
|
203
|
-
| name | type | description |
|
|
204
|
-
| ----- | ------ | ---------------- |
|
|
205
|
-
| key | string | key for the data |
|
|
206
|
-
| value | string | data value |
|
|
207
|
-
|
|
208
|
-
###### Example
|
|
209
|
-
|
|
210
|
-
```cs
|
|
211
|
-
var txn = lobbyManager.GetLobbyUpdateTransaction();
|
|
212
|
-
txn.SetMetadata("average_mmr", "4500");
|
|
213
|
-
lobbyManager.UpdateLobby(lobbyId, txn, (Discord.Result result) =>
|
|
214
|
-
{
|
|
215
|
-
if (result == Discord.Result.Ok)
|
|
216
|
-
{
|
|
217
|
-
Console.WriteLine("Lobby metadata updated!");
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
## LobbyTransaction.DeleteMetadata
|
|
223
|
-
|
|
224
|
-
Deletes the lobby metadata for a key.
|
|
225
|
-
|
|
226
|
-
Returns `void`.
|
|
227
|
-
|
|
228
|
-
###### Parameters
|
|
229
|
-
|
|
230
|
-
| name | type | description |
|
|
231
|
-
| ---- | ------ | ---------------- |
|
|
232
|
-
| key | string | key for the data |
|
|
233
|
-
|
|
234
|
-
###### Example
|
|
235
|
-
|
|
236
|
-
```cs
|
|
237
|
-
var txn = lobbyManager.GetLobbyUpdateTransaction();
|
|
238
|
-
txn.DeleteMetadata("average_mmr");
|
|
239
|
-
lobbyManager.UpdateLobby(lobbyId, txn, (Discord.Result result) =>
|
|
240
|
-
{
|
|
241
|
-
if (result == Discord.Result.Ok)
|
|
242
|
-
{
|
|
243
|
-
Console.WriteLine("Lobby metadata updated!");
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
## LobbyTransaction.SetLocked
|
|
249
|
-
|
|
250
|
-
Sets the lobby to locked or unlocked. When locked, new users cannot join the lobby.
|
|
251
|
-
|
|
252
|
-
Returns `void`.
|
|
253
|
-
|
|
254
|
-
###### Parameters
|
|
255
|
-
|
|
256
|
-
| name | type | description |
|
|
257
|
-
| ------ | ---- | ----------------------------------- |
|
|
258
|
-
| locked | bool | whether to lock or unlock the lobby |
|
|
259
|
-
|
|
260
|
-
###### Example
|
|
261
|
-
|
|
262
|
-
```cs
|
|
263
|
-
var txn = lobbyManager.GetLobbyUpdateTransaction();
|
|
264
|
-
txn.SetLocked(true);
|
|
265
|
-
lobbyManager.UpdateLobby(lobbyId, txn, (Discord.Result result) =>
|
|
266
|
-
{
|
|
267
|
-
if (result == Discord.Result.Ok)
|
|
268
|
-
{
|
|
269
|
-
Console.WriteLine("Lobby type updated!");
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
## LobbyMemberTransaction.SetMetadata
|
|
275
|
-
|
|
276
|
-
Sets metadata value under a given key name for the current user.
|
|
277
|
-
|
|
278
|
-
Returns `void`.
|
|
279
|
-
|
|
280
|
-
###### Parameters
|
|
281
|
-
|
|
282
|
-
| name | type | description |
|
|
283
|
-
| ----- | ------ | ---------------- |
|
|
284
|
-
| key | string | key for the data |
|
|
285
|
-
| value | string | data value |
|
|
286
|
-
|
|
287
|
-
###### Example
|
|
288
|
-
|
|
289
|
-
```cs
|
|
290
|
-
var txn = lobbyManager.GetMemberUpdateTransaction();
|
|
291
|
-
txn.SetMetadata("current_mmr", "4267");
|
|
292
|
-
lobbyManager.UpdateMember(lobbyId, memberId, txn, (result) =>
|
|
293
|
-
{
|
|
294
|
-
if (result == Discord.Result.Ok)
|
|
295
|
-
{
|
|
296
|
-
Console.WriteLine("Member metadata updated!");
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
## LobbyMemberTransaction.DeleteMetadata
|
|
302
|
-
|
|
303
|
-
Sets metadata value under a given key name for the current user.
|
|
304
|
-
|
|
305
|
-
Returns `void`.
|
|
306
|
-
|
|
307
|
-
###### Parameters
|
|
308
|
-
|
|
309
|
-
| name | type | description |
|
|
310
|
-
| ---- | ------ | ---------------- |
|
|
311
|
-
| key | string | key for the data |
|
|
312
|
-
|
|
313
|
-
###### Example
|
|
314
|
-
|
|
315
|
-
```cs
|
|
316
|
-
var txn = lobbyManager.GetMemberUpdateTransaction();
|
|
317
|
-
txn.DeleteMetadata("current_mmr");
|
|
318
|
-
lobbyManager.UpdateMember(lobbyId, memberId, txn, (result) =>
|
|
319
|
-
{
|
|
320
|
-
if (result == Discord.Result.Ok)
|
|
321
|
-
{
|
|
322
|
-
Console.WriteLine("Member metadata updated!");
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
## LobbySearchQuery.Filter
|
|
328
|
-
|
|
329
|
-
Filters lobbies based on metadata comparison. Available filter values are `owner_id`, `capacity`, `slots`, and `metadata`. If you are filtering based on metadata, make sure you prepend your key with `"metadata."` For example, filtering on matchmaking rating would be `"metadata.matchmaking_rating"`.
|
|
330
|
-
|
|
331
|
-
Returns `void`.
|
|
332
|
-
|
|
333
|
-
###### Parameters
|
|
334
|
-
|
|
335
|
-
| name | type | description |
|
|
336
|
-
| ----- | --------------------- | -------------------------------------------------------------------------- |
|
|
337
|
-
| key | string | key to search for filter data |
|
|
338
|
-
| comp | LobbySearchComparison | how the value on the lobby metadata should be compared to the search value |
|
|
339
|
-
| cast | LobbySearchCast | should the search value be cast as a string or a number |
|
|
340
|
-
| value | string | the value to filter against |
|
|
341
|
-
|
|
342
|
-
###### Example
|
|
343
|
-
|
|
344
|
-
```cs
|
|
345
|
-
var query = lobbyManager.GetSearchQuery();
|
|
346
|
-
query.Filter("metadata.matchmaking_rating", LobbySearchComparison.GreaterThan, LobbySearchCast.Number, "455");
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
## LobbySearchQuery.Sort
|
|
350
|
-
|
|
351
|
-
Sorts the filtered lobbies based on "near-ness" to a given value.
|
|
352
|
-
|
|
353
|
-
Returns `void`.
|
|
354
|
-
|
|
355
|
-
###### Parameters
|
|
356
|
-
|
|
357
|
-
| name | type | description |
|
|
358
|
-
| ----- | --------------- | ------------------------------------------------------- |
|
|
359
|
-
| key | string | key for the data |
|
|
360
|
-
| cast | LobbySearchCast | should the search value be cast as a string or a number |
|
|
361
|
-
| value | string | the value to sort by |
|
|
362
|
-
|
|
363
|
-
###### Example
|
|
364
|
-
|
|
365
|
-
```cs
|
|
366
|
-
var query = lobbyManager.GetSearchQuery();
|
|
367
|
-
query.Sort("metadata.ELO", LobbySearchCast.Number, "1337");
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
## LobbySearchQuery.Limit
|
|
371
|
-
|
|
372
|
-
Limits the number of lobbies returned in a search.
|
|
373
|
-
|
|
374
|
-
Returns `void`.
|
|
375
|
-
|
|
376
|
-
###### Parameters
|
|
377
|
-
|
|
378
|
-
| name | type | description |
|
|
379
|
-
| ----- | ------ | -------------------------------------- |
|
|
380
|
-
| limit | UInt32 | the number of lobbies to return at max |
|
|
381
|
-
|
|
382
|
-
###### Example
|
|
383
|
-
|
|
384
|
-
```cs
|
|
385
|
-
var query = lobbyManager.GetSearchQuery();
|
|
386
|
-
query.Limit(10);
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
## LobbySearchQuery.Distance
|
|
390
|
-
|
|
391
|
-
Filters lobby results to within certain regions relative to the user's location.
|
|
392
|
-
|
|
393
|
-
Returns `void`.
|
|
394
|
-
|
|
395
|
-
###### Parameters
|
|
396
|
-
|
|
397
|
-
| name | type | description |
|
|
398
|
-
| -------- | --------------------------- | ----------------------------------------------- |
|
|
399
|
-
| distance | Discord.LobbySearchDistance | the distance within which to search for lobbies |
|
|
400
|
-
|
|
401
|
-
###### Example
|
|
402
|
-
|
|
403
|
-
```cs
|
|
404
|
-
var query = lobbyManager.GetSearchQuery();
|
|
405
|
-
query.Distance(LobbySearchDistance.Local);
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
## GetLobbyCreateTransaction
|
|
409
|
-
|
|
410
|
-
Gets a Lobby transaction used for creating a new lobby
|
|
411
|
-
|
|
412
|
-
Returns a `Discord.LobbyTransaction`.
|
|
413
|
-
|
|
414
|
-
###### Parameters
|
|
415
|
-
|
|
416
|
-
None
|
|
417
|
-
|
|
418
|
-
###### Example
|
|
419
|
-
|
|
420
|
-
```cs
|
|
421
|
-
var txn = lobbyManager.GetLobbyCreateTransaction();
|
|
422
|
-
```
|
|
423
|
-
|
|
424
|
-
## GetLobbyUpdateTransaction
|
|
425
|
-
|
|
426
|
-
Gets a lobby transaction used for updating an existing lobby.
|
|
427
|
-
|
|
428
|
-
Returns a `Discord.LobbyTransaction`.
|
|
429
|
-
|
|
430
|
-
###### Parameters
|
|
431
|
-
|
|
432
|
-
| name | type | description |
|
|
433
|
-
| ------- | ----- | ---------------------------- |
|
|
434
|
-
| lobbyId | Int64 | the lobby you want to change |
|
|
435
|
-
|
|
436
|
-
###### Example
|
|
437
|
-
|
|
438
|
-
```cs
|
|
439
|
-
var txn = lobbyManager.GetLobbyUpdateTransaction(290926798626357250);
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
## GetMemberUpdateTransaction
|
|
443
|
-
|
|
444
|
-
Gets a new member transaction for a lobby member in a given lobby.
|
|
445
|
-
|
|
446
|
-
Returns a `Discord.LobbyMemberTransaction`.
|
|
447
|
-
|
|
448
|
-
###### Parameters
|
|
449
|
-
|
|
450
|
-
| name | type | description |
|
|
451
|
-
| ------- | ----- | ---------------------------- |
|
|
452
|
-
| lobbyId | Int64 | the lobby you want to change |
|
|
453
|
-
| userId | Int64 | the user you wish to change |
|
|
454
|
-
|
|
455
|
-
###### Example
|
|
456
|
-
|
|
457
|
-
```cs
|
|
458
|
-
var txn = lobbyManager.GetMemberUpdateTransaction(290926798626357250, 53908232506183680);
|
|
459
|
-
```
|
|
460
|
-
|
|
461
|
-
## CreateLobby
|
|
462
|
-
|
|
463
|
-
Creates a lobby. Creating a lobby auto-joins the connected user to it. **Do not call `SetOwner()` in the transaction for this method.**
|
|
464
|
-
|
|
465
|
-
Returns `Discord.Result` and `ref Discord.Lobby` via callback.
|
|
466
|
-
|
|
467
|
-
###### Parameters
|
|
468
|
-
|
|
469
|
-
| name | type | description |
|
|
470
|
-
| ----------- | ---------------- | ----------------------------------------------------- |
|
|
471
|
-
| transaction | LobbyTransaction | a lobby transaction with set properties like capacity |
|
|
472
|
-
|
|
473
|
-
###### Example
|
|
474
|
-
|
|
475
|
-
```cs
|
|
476
|
-
lobbyManager.CreateLobby(txn, (Discord.Result result, ref Discord.Lobby lobby) =>
|
|
477
|
-
{
|
|
478
|
-
if (result == Discord.Result.Ok)
|
|
479
|
-
{
|
|
480
|
-
Console.WriteLine("Created lobby {0}", lobby.Id);
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
```
|
|
484
|
-
|
|
485
|
-
## UpdateLobby
|
|
486
|
-
|
|
487
|
-
Updates a lobby with data from the given transaction. You _can_ call `SetOwner()` in this transaction.
|
|
488
|
-
|
|
489
|
-
Returns `Discord.Result` via callback.
|
|
490
|
-
|
|
491
|
-
> warn
|
|
492
|
-
> This call has a rate limit of 10 updates per 5 seconds. If you fear you might hit that, it may be a good idea to batch your lobby updates into transactions.
|
|
493
|
-
|
|
494
|
-
###### Parameters
|
|
495
|
-
|
|
496
|
-
| name | type | description |
|
|
497
|
-
| ----------- | ---------------- | ----------------------------------- |
|
|
498
|
-
| lobbyId | Int64 | the lobby you want to change |
|
|
499
|
-
| transaction | LobbyTransaction | the transaction with wanted changes |
|
|
500
|
-
|
|
501
|
-
###### Example
|
|
502
|
-
|
|
503
|
-
```cs
|
|
504
|
-
lobbymanager.UpdateLobby(290926798626357250, transaction, (result) =>
|
|
505
|
-
{
|
|
506
|
-
if (result == Discord.Result.Ok)
|
|
507
|
-
{
|
|
508
|
-
Console.WriteLine("Lobby updated!");
|
|
509
|
-
}
|
|
510
|
-
});
|
|
511
|
-
```
|
|
512
|
-
|
|
513
|
-
## DeleteLobby
|
|
514
|
-
|
|
515
|
-
Deletes a given lobby.
|
|
516
|
-
|
|
517
|
-
Returns `Discord.Result` via callback.
|
|
518
|
-
|
|
519
|
-
###### Parameters
|
|
520
|
-
|
|
521
|
-
| name | type | description |
|
|
522
|
-
| ------- | ----- | ---------------------------- |
|
|
523
|
-
| lobbyId | Int64 | the lobby you want to delete |
|
|
524
|
-
|
|
525
|
-
###### Example
|
|
526
|
-
|
|
527
|
-
```cs
|
|
528
|
-
lobbyManager.DeleteLobby(290926798626357250, (result) =>
|
|
529
|
-
{
|
|
530
|
-
if (result == Discord.Result.Ok)
|
|
531
|
-
{
|
|
532
|
-
Console.WriteLine("Lobby deleted!");
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
```
|
|
536
|
-
|
|
537
|
-
## ConnectLobby
|
|
538
|
-
|
|
539
|
-
Connects the current user to a given lobby. You can be connected to up to five lobbies at a time.
|
|
540
|
-
|
|
541
|
-
Returns `Discord.Result` and `ref Discord.Lobby` via callback.
|
|
542
|
-
|
|
543
|
-
###### Parameters
|
|
544
|
-
|
|
545
|
-
| name | type | description |
|
|
546
|
-
| ----------- | ------ | -------------------------------- |
|
|
547
|
-
| lobbyId | Int64 | the lobby you want to connect to |
|
|
548
|
-
| lobbySecret | string | the password for the lobby |
|
|
549
|
-
|
|
550
|
-
###### Example
|
|
551
|
-
|
|
552
|
-
```cs
|
|
553
|
-
lobbyManager.ConnectLobby(290926798626357250, "363446008341987328:123123", (Discord.Result result, ref Discord.Lobby lobby) =>
|
|
554
|
-
{
|
|
555
|
-
if (result == Discord.Result.Ok)
|
|
556
|
-
{
|
|
557
|
-
Console.WriteLine("Connected to lobby {0}!", lobby.Id);
|
|
558
|
-
}
|
|
559
|
-
});
|
|
560
|
-
```
|
|
561
|
-
|
|
562
|
-
## ConnectLobbyWithActivitySecret
|
|
563
|
-
|
|
564
|
-
Connects the current user to a lobby; requires the special activity secret from the lobby which is a concatenated lobbyId and secret.
|
|
565
|
-
|
|
566
|
-
Returns `Discord.Result` and `ref Discord.Lobby` via callback.
|
|
567
|
-
|
|
568
|
-
###### Parameters
|
|
569
|
-
|
|
570
|
-
| name | type | description |
|
|
571
|
-
| -------------- | ------ | ----------------------------------------- |
|
|
572
|
-
| activitySecret | string | the special activity secret for the lobby |
|
|
573
|
-
|
|
574
|
-
###### Example
|
|
575
|
-
|
|
576
|
-
```cs
|
|
577
|
-
lobbyManager.ConnectLobbyWithActivitySecret("363446008341987328:123123", (Discord.Result result, ref Discord.Lobby lobby) =>
|
|
578
|
-
{
|
|
579
|
-
if (result == Discord.Result.Ok)
|
|
580
|
-
{
|
|
581
|
-
Console.WriteLine("Connected to lobby {0}!", lobby.Id);
|
|
582
|
-
}
|
|
583
|
-
});
|
|
584
|
-
```
|
|
585
|
-
|
|
586
|
-
## GetLobbyActivitySecret
|
|
587
|
-
|
|
588
|
-
Gets the special activity secret for a given lobby. If you are creating lobbies from game clients, use this to easily interact with Rich Presence invites. Set the returned secret to your activity's `JoinSecret`.
|
|
589
|
-
|
|
590
|
-
Returns `string`.
|
|
591
|
-
|
|
592
|
-
###### Parameters
|
|
593
|
-
|
|
594
|
-
| name | type | description |
|
|
595
|
-
| ------- | ----- | ---------------------------------------- |
|
|
596
|
-
| lobbyId | Int64 | the lobby you want to get the secret for |
|
|
597
|
-
|
|
598
|
-
###### Example
|
|
599
|
-
|
|
600
|
-
```cs
|
|
601
|
-
var activitySecret = lobbyManager.GetLobbyActivitySecret(290926798626357250);
|
|
602
|
-
var activity = new Discord.Activity
|
|
603
|
-
{
|
|
604
|
-
State = "olleh",
|
|
605
|
-
Details = "foo details",
|
|
606
|
-
Party = {
|
|
607
|
-
Id = "foo partyID",
|
|
608
|
-
Size = {
|
|
609
|
-
CurrentSize = 1,
|
|
610
|
-
MaxSize = 4,
|
|
611
|
-
},
|
|
612
|
-
},
|
|
613
|
-
Secrets = {
|
|
614
|
-
Join = activitySecret,
|
|
615
|
-
},
|
|
616
|
-
Instance = true,
|
|
617
|
-
};
|
|
618
|
-
|
|
619
|
-
ActivityManager.UpdateActivity(activity, (result) =>
|
|
620
|
-
{
|
|
621
|
-
Console.WriteLine("Update Activity {0}", result);
|
|
622
|
-
});
|
|
623
|
-
```
|
|
624
|
-
|
|
625
|
-
## DisconnectLobby
|
|
626
|
-
|
|
627
|
-
Disconnects the current user from a lobby.
|
|
628
|
-
|
|
629
|
-
Returns `Discord.Result` via callback.
|
|
630
|
-
|
|
631
|
-
###### Parameters
|
|
632
|
-
|
|
633
|
-
| name | type | description |
|
|
634
|
-
| ------- | ----- | --------------------------- |
|
|
635
|
-
| lobbyId | Int64 | the lobby you want to leave |
|
|
636
|
-
|
|
637
|
-
###### Example
|
|
638
|
-
|
|
639
|
-
```cs
|
|
640
|
-
lobbyManager.DisconnectLobby(290926798626357250, (result) =>
|
|
641
|
-
{
|
|
642
|
-
if (result == Discord.Result.Ok)
|
|
643
|
-
{
|
|
644
|
-
Console.WriteLine("Left lobby!");
|
|
645
|
-
}
|
|
646
|
-
});
|
|
647
|
-
```
|
|
648
|
-
|
|
649
|
-
## GetLobby
|
|
650
|
-
|
|
651
|
-
Gets the lobby object for a given lobby id. Because of the way that the SDK is architected, you must first call [`Search()`](#DOCS_GAME_SDK_LOBBIES/search) to build a stable list of lobbies. This function will then query those lobbies for ones with a matching id.
|
|
652
|
-
|
|
653
|
-
Returns a `Discord.Lobby`.
|
|
654
|
-
|
|
655
|
-
###### Parameters
|
|
656
|
-
|
|
657
|
-
| name | type | description |
|
|
658
|
-
| ------- | ----- | ------------------------- |
|
|
659
|
-
| lobbyId | Int64 | the lobby you want to get |
|
|
660
|
-
|
|
661
|
-
###### Example
|
|
662
|
-
|
|
663
|
-
```cs
|
|
664
|
-
var lobbyId = 12345;
|
|
665
|
-
|
|
666
|
-
var query = lobbyManager.GetSearchQuery();
|
|
667
|
-
lobbyManager.Search(query, (res) =>
|
|
668
|
-
{
|
|
669
|
-
if (res == Discord.Result.Ok)
|
|
670
|
-
{
|
|
671
|
-
// This will return you a lobby
|
|
672
|
-
var lobby = lobbyManager.GetLobby(lobbyId);
|
|
673
|
-
}
|
|
674
|
-
});
|
|
675
|
-
|
|
676
|
-
// This will return NotFound
|
|
677
|
-
var lobby_2 = lobbyManager.GetLobby(lobbyId);
|
|
678
|
-
```
|
|
679
|
-
|
|
680
|
-
## LobbyMetadataCount
|
|
681
|
-
|
|
682
|
-
Returns the number of metadata key/value pairs on a given lobby. Used for accessing metadata by iterating over the list.
|
|
683
|
-
|
|
684
|
-
Returns `Int32`.
|
|
685
|
-
|
|
686
|
-
###### Parameters
|
|
687
|
-
|
|
688
|
-
| name | type | description |
|
|
689
|
-
| ------- | ----- | -------------------------------------- |
|
|
690
|
-
| lobbyId | Int64 | the lobby you want to get metadata for |
|
|
691
|
-
|
|
692
|
-
###### Example
|
|
693
|
-
|
|
694
|
-
```cs
|
|
695
|
-
var count = lobbyManager.LobbyMetadataCount(290926798626357250);
|
|
696
|
-
for (int i = 0; i < count; i++)
|
|
697
|
-
{
|
|
698
|
-
var value = lobbyManager.GetLobbyMetadataKey(290926798626357250, i);
|
|
699
|
-
}
|
|
700
|
-
```
|
|
701
|
-
|
|
702
|
-
## GetLobbyMetadataKey
|
|
703
|
-
|
|
704
|
-
Returns the key for the lobby metadata at the given index.
|
|
705
|
-
|
|
706
|
-
Returns `string`.
|
|
707
|
-
|
|
708
|
-
###### Parameters
|
|
709
|
-
|
|
710
|
-
| name | type | description |
|
|
711
|
-
| ------- | ----- | -------------------------------------- |
|
|
712
|
-
| lobbyId | Int64 | the lobby you want to get metadata for |
|
|
713
|
-
| index | Int32 | the index of lobby metadata to access |
|
|
714
|
-
|
|
715
|
-
###### Example
|
|
716
|
-
|
|
717
|
-
```cs
|
|
718
|
-
var count = lobbyManager.GetLobbyMetadataCount(290926798626357250);
|
|
719
|
-
for (int i = 0; i < count; i++)
|
|
720
|
-
{
|
|
721
|
-
var value = lobbyManager.GetLobbyMetadataKey(290926798626357250, i);
|
|
722
|
-
}
|
|
723
|
-
```
|
|
724
|
-
|
|
725
|
-
## GetLobbyMetadataValue
|
|
726
|
-
|
|
727
|
-
Returns lobby metadata value for a given key and id. Can be used with iteration, or direct access by keyname.
|
|
728
|
-
|
|
729
|
-
###### Parameters
|
|
730
|
-
|
|
731
|
-
| name | type | description |
|
|
732
|
-
| ------- | ------ | -------------------------------------- |
|
|
733
|
-
| lobbyId | Int64 | the lobby you want to get metadata for |
|
|
734
|
-
| key | string | the key name to access |
|
|
735
|
-
|
|
736
|
-
###### Example
|
|
737
|
-
|
|
738
|
-
```cs
|
|
739
|
-
var averageMmr = lobbyManager.GetLobbyMetadataValue(290926798626357250, "metadata.average_mmr");
|
|
740
|
-
```
|
|
741
|
-
|
|
742
|
-
## MemberCount
|
|
743
|
-
|
|
744
|
-
Get the number of members in a lobby.
|
|
745
|
-
|
|
746
|
-
Returns `Int32`.
|
|
747
|
-
|
|
748
|
-
###### Parameters
|
|
749
|
-
|
|
750
|
-
| name | type | description |
|
|
751
|
-
| ------- | ----- | ------------------------------------- |
|
|
752
|
-
| lobbyId | Int64 | the lobby you want to get members for |
|
|
753
|
-
|
|
754
|
-
###### Example
|
|
755
|
-
|
|
756
|
-
```cs
|
|
757
|
-
var count = lobbyManager.MemberCount(290926798626357250);
|
|
758
|
-
for (int i = 0; i < count; i++)
|
|
759
|
-
{
|
|
760
|
-
var id = lobbyManager.GetMemberUserId(290926798626357250, i);
|
|
761
|
-
}
|
|
762
|
-
```
|
|
763
|
-
|
|
764
|
-
## GetMemberUserId
|
|
765
|
-
|
|
766
|
-
Gets the user id of the lobby member at the given index.
|
|
767
|
-
|
|
768
|
-
Returns `Int64`.
|
|
769
|
-
|
|
770
|
-
###### Parameters
|
|
771
|
-
|
|
772
|
-
| name | type | description |
|
|
773
|
-
| ------- | ----- | ------------------------------------- |
|
|
774
|
-
| lobbyId | Int64 | the lobby you want to get members for |
|
|
775
|
-
| index | Int32 | the index of lobby member to access |
|
|
776
|
-
|
|
777
|
-
###### Example
|
|
778
|
-
|
|
779
|
-
```cs
|
|
780
|
-
var count = lobbyManager.MemberCount(290926798626357250);
|
|
781
|
-
for (int i = 0; i < count; i++)
|
|
782
|
-
{
|
|
783
|
-
var id = lobbyManager.GetMemberUserId(290926798626357250, i);
|
|
784
|
-
}
|
|
785
|
-
```
|
|
786
|
-
|
|
787
|
-
## GetMemberUser
|
|
788
|
-
|
|
789
|
-
Gets the user object for a given user id.
|
|
790
|
-
|
|
791
|
-
Returns `Discord.User`.
|
|
792
|
-
|
|
793
|
-
###### Parameters
|
|
794
|
-
|
|
795
|
-
| name | type | description |
|
|
796
|
-
| ------- | ----- | ------------------------------------- |
|
|
797
|
-
| lobbyId | Int64 | the lobby you want to get members for |
|
|
798
|
-
| userId | Int64 | the user's userId |
|
|
799
|
-
|
|
800
|
-
###### Example
|
|
801
|
-
|
|
802
|
-
```cs
|
|
803
|
-
var count = lobbyManager.MemberCount(290926798626357250);
|
|
804
|
-
for (int i = 0; i < count; i++)
|
|
805
|
-
{
|
|
806
|
-
var id = lobbyManager.GetMemberUserId(290926798626357250, i);
|
|
807
|
-
var user = lobbyManager.GetMemberUser(290926798626357250, id);
|
|
808
|
-
Console.WriteLine("Got user {0}", user.Id);
|
|
809
|
-
}
|
|
810
|
-
```
|
|
811
|
-
|
|
812
|
-
## MemberMetadataCount
|
|
813
|
-
|
|
814
|
-
Gets the number of metadata key/value pairs for the given lobby member. Used for accessing metadata by iterating over a list.
|
|
815
|
-
|
|
816
|
-
Returns `Int32`.
|
|
817
|
-
|
|
818
|
-
###### Parameters
|
|
819
|
-
|
|
820
|
-
| name | type | description |
|
|
821
|
-
| ------- | ----- | -------------------------------------- |
|
|
822
|
-
| lobbyId | Int64 | the lobby the member belongs to |
|
|
823
|
-
| userId | Int64 | the id of the user to get metadata for |
|
|
824
|
-
|
|
825
|
-
###### Example
|
|
826
|
-
|
|
827
|
-
```cs
|
|
828
|
-
var count = lobbyManager.MemberMetadataCount(290926798626357250, 53908232506183680);
|
|
829
|
-
for (int i = 0; i < count; i++)
|
|
830
|
-
{
|
|
831
|
-
var key = lobbyManager.GetMemberMetadataKey(290926798626357250, 53908232506183680, i);
|
|
832
|
-
}
|
|
833
|
-
```
|
|
834
|
-
|
|
835
|
-
## GetMemberMetadataKey
|
|
836
|
-
|
|
837
|
-
Gets the key for the lobby metadata at the given index on a lobby member.
|
|
838
|
-
|
|
839
|
-
Returns `string`.
|
|
840
|
-
|
|
841
|
-
###### Parameters
|
|
842
|
-
|
|
843
|
-
| name | type | description |
|
|
844
|
-
| ------- | ----- | -------------------------------------- |
|
|
845
|
-
| lobbyId | Int64 | the lobby the member belongs to |
|
|
846
|
-
| userId | Int64 | the id of the user to get metadata for |
|
|
847
|
-
| index | Int32 | the index of metadata to access |
|
|
848
|
-
|
|
849
|
-
###### Example
|
|
850
|
-
|
|
851
|
-
```cs
|
|
852
|
-
var count = lobbyManager.MemberMetadataCount(290926798626357250, 53908232506183680);
|
|
853
|
-
for (int i = 0; i < count; i++)
|
|
854
|
-
{
|
|
855
|
-
var key = lobbyManager.GetMemberMetadataKey(290926798626357250, 53908232506183680, i);
|
|
856
|
-
}
|
|
857
|
-
```
|
|
858
|
-
|
|
859
|
-
## GetMemberMetadataValue
|
|
860
|
-
|
|
861
|
-
Returns user metadata for a given key. Can be used in conjunction with the count and get key functions if you're iterating over metadata. Or you can access the metadata directly by keyname
|
|
862
|
-
|
|
863
|
-
Returns `string`.
|
|
864
|
-
|
|
865
|
-
###### Parameters
|
|
866
|
-
|
|
867
|
-
| name | type | description |
|
|
868
|
-
| ------- | ------ | -------------------------------------- |
|
|
869
|
-
| lobbyId | Int64 | the lobby the member belongs to |
|
|
870
|
-
| userId | Int64 | the id of the user to get metadata for |
|
|
871
|
-
| key | string | the metadata key to access |
|
|
872
|
-
|
|
873
|
-
###### Example
|
|
874
|
-
|
|
875
|
-
```cs
|
|
876
|
-
var count = lobbyManager.MemberMetadataCount(290926798626357250, 53908232506183680);
|
|
877
|
-
for (int i = 0; i < count; i++)
|
|
878
|
-
{
|
|
879
|
-
var key = lobbyManager.GetMemberMetadataKey(290926798626357250, 53908232506183680, i);
|
|
880
|
-
var value = lobbyManager.GetMemberMetadataValue(290926798626357250, 53908232506183680, key);
|
|
881
|
-
Console.WriteLine("Value: {0}", value);
|
|
882
|
-
}
|
|
883
|
-
```
|
|
884
|
-
|
|
885
|
-
## UpdateMember
|
|
886
|
-
|
|
887
|
-
Updates lobby member info for a given member of the lobby.
|
|
888
|
-
|
|
889
|
-
Returns `Discord.Result` via callback.
|
|
890
|
-
|
|
891
|
-
###### Parameters
|
|
892
|
-
|
|
893
|
-
| name | type | description |
|
|
894
|
-
| ----------- | ---------------------- | --------------------------------- |
|
|
895
|
-
| lobbyId | Int64 | lobby the member belongs to |
|
|
896
|
-
| userId | Int64 | id of the user |
|
|
897
|
-
| transaction | LobbyMemberTransaction | transaction with the changed data |
|
|
898
|
-
|
|
899
|
-
###### Example
|
|
900
|
-
|
|
901
|
-
```cs
|
|
902
|
-
var txn = lobbyManager.GetMemberUpdateTransaction();
|
|
903
|
-
txn.SetMetadata("my_mmr", "9999");
|
|
904
|
-
lobbyManager.UpdateMember(290926798626357250, 53908232506183680, txn, (result) =>
|
|
905
|
-
{
|
|
906
|
-
if (result == Discord.Result.Ok)
|
|
907
|
-
{
|
|
908
|
-
Console.WriteLine("Lobby member updated!");
|
|
909
|
-
}
|
|
910
|
-
});
|
|
911
|
-
```
|
|
912
|
-
|
|
913
|
-
## SendLobbyMessage
|
|
914
|
-
|
|
915
|
-
Sends a message to the lobby on behalf of the current user. You must be connected to the lobby you are messaging. You should use this function for message sending if you are _not_ using the built in networking layer for the lobby. If you are, you should use [SendNetworkMessage](#DOCS_GAME_SDK_LOBBIES/sendnetworkmessage) instead.
|
|
916
|
-
|
|
917
|
-
This method has a rate limit of 10 messages per 5 seconds.
|
|
918
|
-
|
|
919
|
-
Returns a `Discord.Result` via callback.
|
|
920
|
-
|
|
921
|
-
###### Parameters
|
|
922
|
-
|
|
923
|
-
| name | type | description |
|
|
924
|
-
| ------- | ------ | --------------------------- |
|
|
925
|
-
| lobbyId | Int64 | lobby the member belongs to |
|
|
926
|
-
| data | byte[] | the data to send |
|
|
927
|
-
|
|
928
|
-
###### Example
|
|
929
|
-
|
|
930
|
-
```cs
|
|
931
|
-
lobbyManager.SendLobbyMessage(290926798626357250, Encoding.UTF8.GetBytes("hey."), (result) =>
|
|
932
|
-
{
|
|
933
|
-
if (result == Discord.Result.Ok)
|
|
934
|
-
{
|
|
935
|
-
Console.WriteLine("Message sent successfully");
|
|
936
|
-
}
|
|
937
|
-
});
|
|
938
|
-
```
|
|
939
|
-
|
|
940
|
-
## GetSearchQuery
|
|
941
|
-
|
|
942
|
-
Creates a search object to search available lobbies.
|
|
943
|
-
|
|
944
|
-
Returns `Discord.LobbySearchQuery`.
|
|
945
|
-
|
|
946
|
-
###### Parameters
|
|
947
|
-
|
|
948
|
-
None
|
|
949
|
-
|
|
950
|
-
###### Example
|
|
951
|
-
|
|
952
|
-
```cs
|
|
953
|
-
var search = lobbyManager.GetSearchQuery();
|
|
954
|
-
```
|
|
955
|
-
|
|
956
|
-
## Search
|
|
957
|
-
|
|
958
|
-
Searches available lobbies based on the search criteria chosen in the `Discord.LobbySearch` member functions. Lobbies that meet the criteria are then globally filtered, and can be accessed via iteration with `LobbyCount()` and `GetLobbyId()`. The callback fires when the list of lobbies is stable and ready for iteration.
|
|
959
|
-
|
|
960
|
-
You do not necessarily need to access the filtered lobbies within the context of the result callback, but it may make it easier for the sake of asynchronous timing.
|
|
961
|
-
|
|
962
|
-
Returns `Discord.Result` via callback.
|
|
963
|
-
|
|
964
|
-
###### Parameters
|
|
965
|
-
|
|
966
|
-
| name | type | description |
|
|
967
|
-
| ------ | ----------- | ------------------- |
|
|
968
|
-
| search | LobbySearch | the search criteria |
|
|
969
|
-
|
|
970
|
-
###### Example
|
|
971
|
-
|
|
972
|
-
```cs
|
|
973
|
-
var search = lobbyManger.GetSearchQuery();
|
|
974
|
-
search.Filter("metadata.matchmaking_rating", LobbySearchComparison.GreaterThan, LobbySearchCast.Number, "455");
|
|
975
|
-
search.Sort("metadata.matchmaking_rating", LobbySearchCast.Number, "456");
|
|
976
|
-
search.Limit(10);
|
|
977
|
-
lobbyManager.Search(search, (result) =>
|
|
978
|
-
{
|
|
979
|
-
if (result == Discord.Result.Ok)
|
|
980
|
-
{
|
|
981
|
-
var count = lobbyManager.LobbyCount();
|
|
982
|
-
Console.WriteLine("There are {0} lobbies that match your search criteria", count);
|
|
983
|
-
}
|
|
984
|
-
});
|
|
985
|
-
```
|
|
986
|
-
|
|
987
|
-
## LobbyCount
|
|
988
|
-
|
|
989
|
-
Get the number of lobbies that match the search.
|
|
990
|
-
|
|
991
|
-
Returns `Int32`.
|
|
992
|
-
|
|
993
|
-
###### Parameters
|
|
994
|
-
|
|
995
|
-
None
|
|
996
|
-
|
|
997
|
-
###### Example
|
|
998
|
-
|
|
999
|
-
```cs
|
|
1000
|
-
lobbyManager.Search(search, () =>
|
|
1001
|
-
{
|
|
1002
|
-
var count = lobbyManager.LobbyCount();
|
|
1003
|
-
Console.WriteLine("There are {0} lobbies that match your search criteria", count);
|
|
1004
|
-
});
|
|
1005
|
-
```
|
|
1006
|
-
|
|
1007
|
-
## GetLobbyId
|
|
1008
|
-
|
|
1009
|
-
Returns the id for the lobby at the given index.
|
|
1010
|
-
|
|
1011
|
-
Returns `Int64`.
|
|
1012
|
-
|
|
1013
|
-
###### Parameters
|
|
1014
|
-
|
|
1015
|
-
| name | type | description |
|
|
1016
|
-
| ----- | ----- | ------------------------------------------------ |
|
|
1017
|
-
| index | Int32 | the index at which to access the list of lobbies |
|
|
1018
|
-
|
|
1019
|
-
###### Example
|
|
1020
|
-
|
|
1021
|
-
```cs
|
|
1022
|
-
lobbyManager.Search(search, () =>
|
|
1023
|
-
{
|
|
1024
|
-
var count = lobbyManager.LobbyCount();
|
|
1025
|
-
for (int i = 0; i < count; i++)
|
|
1026
|
-
{
|
|
1027
|
-
var id = lobbyManager.GetLobbyId(i);
|
|
1028
|
-
Console.WriteLine("Found lobby {0}", id);
|
|
1029
|
-
}
|
|
1030
|
-
});
|
|
1031
|
-
```
|
|
1032
|
-
|
|
1033
|
-
## ConnectVoice
|
|
1034
|
-
|
|
1035
|
-
Connects to the voice channel of the current lobby. When connected to voice, the user can open their Discord overlay to see a list of other users with whom they are in voice, allowing them to mute/deafen themselves as well as mute/adjust the volume of other lobby members.
|
|
1036
|
-
|
|
1037
|
-
You can also allow users to adjust voice settings for your game with [Overlay OpenVoiceSettings](#DOCS_GAME_SDK_OVERLAY/openvoicesettings).
|
|
1038
|
-
|
|
1039
|
-
When integrating lobby voice into your game, be thoughtful about the user's experience. Auto-joining to voice can be jarring for users who may not be expecting it. We recommend voice always being opt-in, or at least that you provide an option for a player to choose whether or not to auto-join the voice channel of lobbies they join.
|
|
1040
|
-
|
|
1041
|
-
Returns `Discord.Result` via callback.
|
|
1042
|
-
|
|
1043
|
-
###### Parameters
|
|
1044
|
-
|
|
1045
|
-
| name | type | description |
|
|
1046
|
-
| ------- | ----- | ------------------------- |
|
|
1047
|
-
| lobbyId | Int64 | lobby to voice connect to |
|
|
1048
|
-
|
|
1049
|
-
###### Example
|
|
1050
|
-
|
|
1051
|
-
```cs
|
|
1052
|
-
lobbyManager.ConnectVoice(290926798626357250, (result) =>
|
|
1053
|
-
{
|
|
1054
|
-
if (result == Discord.Result.Ok)
|
|
1055
|
-
{
|
|
1056
|
-
Console.WriteLine("Voice connected!");
|
|
1057
|
-
}
|
|
1058
|
-
});
|
|
1059
|
-
```
|
|
1060
|
-
|
|
1061
|
-
## DisconnectVoice
|
|
1062
|
-
|
|
1063
|
-
Disconnects from the voice channel of a given lobby.
|
|
1064
|
-
|
|
1065
|
-
Returns `Discord.Result` via callback.
|
|
1066
|
-
|
|
1067
|
-
###### Parameters
|
|
1068
|
-
|
|
1069
|
-
| name | type | description |
|
|
1070
|
-
| ------- | ----- | ------------------------------ |
|
|
1071
|
-
| lobbyId | Int64 | lobby to voice disconnect from |
|
|
1072
|
-
|
|
1073
|
-
###### Example
|
|
1074
|
-
|
|
1075
|
-
```cs
|
|
1076
|
-
lobbyManager.DisconnectVoice(290926798626357250, (result) =>
|
|
1077
|
-
{
|
|
1078
|
-
if (result == Discord.Result.Ok)
|
|
1079
|
-
{
|
|
1080
|
-
Console.WriteLine("Voice disconnected!");
|
|
1081
|
-
}
|
|
1082
|
-
});
|
|
1083
|
-
```
|
|
1084
|
-
|
|
1085
|
-
## OnLobbyUpdate
|
|
1086
|
-
|
|
1087
|
-
Fires when a lobby is updated.
|
|
1088
|
-
|
|
1089
|
-
###### Parameters
|
|
1090
|
-
|
|
1091
|
-
| name | type | description |
|
|
1092
|
-
| ------- | ----- | ------------------ |
|
|
1093
|
-
| lobbyId | Int64 | lobby that updated |
|
|
1094
|
-
|
|
1095
|
-
###### Example
|
|
1096
|
-
|
|
1097
|
-
```cs
|
|
1098
|
-
lobbyManager.OnLobbyUpdate += (lobbyID) =>
|
|
1099
|
-
{
|
|
1100
|
-
Console.WriteLine("lobby successfully updated: {0}", lobbyID);
|
|
1101
|
-
};
|
|
1102
|
-
```
|
|
1103
|
-
|
|
1104
|
-
## OnLobbyDelete
|
|
1105
|
-
|
|
1106
|
-
Fired when a lobby is deleted.
|
|
1107
|
-
|
|
1108
|
-
###### Parameters
|
|
1109
|
-
|
|
1110
|
-
| name | type | description |
|
|
1111
|
-
| ------- | ------ | ---------------------------------------------- |
|
|
1112
|
-
| lobbyId | Int64 | lobby that was deleted |
|
|
1113
|
-
| reason | string | reason for deletion - this is a system message |
|
|
1114
|
-
|
|
1115
|
-
###### Example
|
|
1116
|
-
|
|
1117
|
-
```cs
|
|
1118
|
-
lobbyManager.OnLobbyDelete += (lobbyID, reason) =>
|
|
1119
|
-
{
|
|
1120
|
-
Console.WriteLine("lobby successfully deleted: {0} with reason: {1}", lobbyID, reason);
|
|
1121
|
-
};
|
|
1122
|
-
```
|
|
1123
|
-
|
|
1124
|
-
## OnMemberConnect
|
|
1125
|
-
|
|
1126
|
-
Fires when a new member joins the lobby.
|
|
1127
|
-
|
|
1128
|
-
###### Parameters
|
|
1129
|
-
|
|
1130
|
-
| name | type | description |
|
|
1131
|
-
| ------- | ----- | --------------------- |
|
|
1132
|
-
| lobbyId | Int64 | lobby the user joined |
|
|
1133
|
-
| userId | Int64 | user that joined |
|
|
1134
|
-
|
|
1135
|
-
###### Example
|
|
1136
|
-
|
|
1137
|
-
```cs
|
|
1138
|
-
lobbyManager.OnMemberConnect += (lobbyID, userID) =>
|
|
1139
|
-
{
|
|
1140
|
-
Console.WriteLine("user {0} connected to lobby: {1}", userID, lobbyID);
|
|
1141
|
-
};
|
|
1142
|
-
```
|
|
1143
|
-
|
|
1144
|
-
## OnMemberUpdate
|
|
1145
|
-
|
|
1146
|
-
Fires when data for a lobby member is updated.
|
|
1147
|
-
|
|
1148
|
-
###### Parameters
|
|
1149
|
-
|
|
1150
|
-
| name | type | description |
|
|
1151
|
-
| ------- | ----- | ----------------------------- |
|
|
1152
|
-
| lobbyId | Int64 | lobby the user is a member of |
|
|
1153
|
-
| userId | Int64 | user that was updated |
|
|
1154
|
-
|
|
1155
|
-
###### Example
|
|
1156
|
-
|
|
1157
|
-
```cs
|
|
1158
|
-
lobbyManager.OnMemberUpdate += (lobbyID, userID) =>
|
|
1159
|
-
{
|
|
1160
|
-
Console.WriteLine("user {0} got updated in lobby: {1}", userID, lobbyID);
|
|
1161
|
-
};
|
|
1162
|
-
```
|
|
1163
|
-
|
|
1164
|
-
## OnMemberDisconnect
|
|
1165
|
-
|
|
1166
|
-
Fires when a member leaves the lobby.
|
|
1167
|
-
|
|
1168
|
-
###### Parameters
|
|
1169
|
-
|
|
1170
|
-
| name | type | description |
|
|
1171
|
-
| ------- | ----- | ------------------------------ |
|
|
1172
|
-
| lobbyId | Int64 | lobby the user was a member of |
|
|
1173
|
-
| userId | Int64 | user that left |
|
|
1174
|
-
|
|
1175
|
-
###### Example
|
|
1176
|
-
|
|
1177
|
-
```cs
|
|
1178
|
-
lobbyManager.OnMemberDisconnect += (lobbyID, userID) =>
|
|
1179
|
-
{
|
|
1180
|
-
Console.WriteLine("user {0} disconnected from lobby: {1}", userID, lobbyID);
|
|
1181
|
-
};
|
|
1182
|
-
```
|
|
1183
|
-
|
|
1184
|
-
## OnLobbyMessage
|
|
1185
|
-
|
|
1186
|
-
Fires when a message is sent to the lobby.
|
|
1187
|
-
|
|
1188
|
-
###### Parameters
|
|
1189
|
-
|
|
1190
|
-
| name | type | description |
|
|
1191
|
-
| ------- | ------ | ---------------------------- |
|
|
1192
|
-
| lobbyId | Int64 | lobby the message is sent to |
|
|
1193
|
-
| userId | Int64 | user that sent the message |
|
|
1194
|
-
| data | byte[] | the message contents |
|
|
1195
|
-
|
|
1196
|
-
###### Example
|
|
1197
|
-
|
|
1198
|
-
```cs
|
|
1199
|
-
lobbyManager.OnLobbyMessage += (lobbyID, userID, data) =>
|
|
1200
|
-
{
|
|
1201
|
-
Console.WriteLine("lobby message: {0}, user who sent the message: {1}, Containing: {2}", lobbyID, userID, Encoding.UTF8.GetString(data));
|
|
1202
|
-
};
|
|
1203
|
-
```
|
|
1204
|
-
|
|
1205
|
-
## OnSpeaking
|
|
1206
|
-
|
|
1207
|
-
Fires when a user connected to voice starts or stops speaking.
|
|
1208
|
-
|
|
1209
|
-
###### Parameters
|
|
1210
|
-
|
|
1211
|
-
| name | type | description |
|
|
1212
|
-
| -------- | ----- | ------------------------------------------------------- |
|
|
1213
|
-
| lobbyId | Int64 | lobby the user is connected to |
|
|
1214
|
-
| userId | Int64 | user in voice |
|
|
1215
|
-
| speaking | bool | `true` == started speaking, `false` == stopped speaking |
|
|
1216
|
-
|
|
1217
|
-
###### Example
|
|
1218
|
-
|
|
1219
|
-
```cs
|
|
1220
|
-
lobbyManager.OnSpeaking += (lobbyID, userID, speaking) =>
|
|
1221
|
-
{
|
|
1222
|
-
Console.WriteLine("lobby speaking: {0} {1} {2}", lobbyID, userID, speaking);
|
|
1223
|
-
};
|
|
1224
|
-
```
|
|
1225
|
-
|
|
1226
|
-
## Connecting to Lobbies
|
|
1227
|
-
|
|
1228
|
-
In the preceding section, you probably noticed there are a couple different methods for connecting to a lobby: `Connect()` and `ConnectWithActivitySecret()`. Lobbies in Discord are even more useful when hooked together with Activities/Rich Presence functionality; they give you everything you need to create an awesome game invite system.
|
|
1229
|
-
|
|
1230
|
-
If you are creating lobbies for users in the game client, and not on a backend server, consider using `GetLobbyActivitySecret` and `ConnectWithActivitySecret()`. `GetLobbyActivitySecret()` will return you a unique secret for the lobby concatenated with the lobby's id. You can pipe this value directly to the `Secrets.Join` field of the `Activity` payload. Then, when a user receives the secret, their client can call `ConnectWithActivitySecret()` with just the secret; the lobby id is parsed out automatically. This saves you the effort of concatenating the secret + id together yourself and then parsing them out again. As a code example:
|
|
1231
|
-
|
|
1232
|
-
```cs
|
|
1233
|
-
var discord = new Discord.Discord(clientId, Discord.CreateFlags.Default);
|
|
1234
|
-
var lobbyManager = discord.GetLobbyManager();
|
|
1235
|
-
var activityManager = discord.GetActivityManager();
|
|
1236
|
-
|
|
1237
|
-
// Create a lobby
|
|
1238
|
-
var txn = lobbyManager.GetLobbyCreateTransaction();
|
|
1239
|
-
txn.SetCapacity(5);
|
|
1240
|
-
txn.SetType(Discord.LobbyType.Private);
|
|
1241
|
-
|
|
1242
|
-
lobbyManager.CreateLobby(txn, (Discord.Result result, ref Discord.Lobby lobby) =>
|
|
1243
|
-
{
|
|
1244
|
-
// Get the special activity secret
|
|
1245
|
-
var secret = lobbyManager.GetLobbyActivitySecret(lobby.id);
|
|
1246
|
-
|
|
1247
|
-
// Create a new activity
|
|
1248
|
-
// Set the party id to the lobby id, so everyone in the lobby has the same value
|
|
1249
|
-
// Set the join secret to the special activity secret
|
|
1250
|
-
var activity = new Discord.Activity
|
|
1251
|
-
{
|
|
1252
|
-
Party =
|
|
1253
|
-
{
|
|
1254
|
-
Id = lobby.id,
|
|
1255
|
-
Size = {
|
|
1256
|
-
CurrentSize = 1,
|
|
1257
|
-
MaxSize = 5
|
|
1258
|
-
}
|
|
1259
|
-
},
|
|
1260
|
-
Secrets =
|
|
1261
|
-
{
|
|
1262
|
-
Join = secret
|
|
1263
|
-
}
|
|
1264
|
-
};
|
|
1265
|
-
|
|
1266
|
-
activityManager.UpdateActivity(activity, (result) =>
|
|
1267
|
-
{
|
|
1268
|
-
// Now, you can send chat invites, or others can ask to join
|
|
1269
|
-
// When other clients receive the OnActivityJoin() event, they'll receive the special activity secret
|
|
1270
|
-
// They can then directly call lobbyManager.ConnectLobbyWithActivitySecret() and be put into the lobby together
|
|
1271
|
-
})
|
|
1272
|
-
});
|
|
1273
|
-
```
|
|
1274
|
-
|
|
1275
|
-
If you are creating lobbies with your own backend system (see the section below), this method may not be useful for you. In that case, you can use `Connect()` and pass the lobby id and secret as you normally would. If you're hooking up to Activities, just make sure you send both the lobby secret and the lobby id in the `Secrets.Join` field, so anyone who tries to join has the right data.
|
|
1276
|
-
|
|
1277
|
-
### Example: Search for a Lobby, Connect, and Join Voice
|
|
1278
|
-
|
|
1279
|
-
```cs
|
|
1280
|
-
var discord = new Discord.Discord(clientId, Discord.CreateFlags.Default);
|
|
1281
|
-
|
|
1282
|
-
// Search lobbies.
|
|
1283
|
-
var query = lobbyManager.GetSearchQuery();
|
|
1284
|
-
|
|
1285
|
-
// Filter by a metadata value.
|
|
1286
|
-
query.Filter("metadata.ELO", Discord.LobbySearchComparison.EqualTo, Discord.LobbySearchCast.Number, "1337");
|
|
1287
|
-
|
|
1288
|
-
// Only return 1 result max.
|
|
1289
|
-
query.Limit(1);
|
|
1290
|
-
|
|
1291
|
-
lobbyManager.Search(query, () =>
|
|
1292
|
-
{
|
|
1293
|
-
Console.WriteLine("search returned {0} lobbies", lobbyManager.LobbyCount());
|
|
1294
|
-
|
|
1295
|
-
if (lobbyManager.LobbyCount() == 1)
|
|
1296
|
-
{
|
|
1297
|
-
Console.WriteLine("first lobby: {0}", lobbyManager.GetLobbyId(0));
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
// Get the id of the lobby, and connect to voice
|
|
1301
|
-
var id = lobbyManager.GetLobbyId(0);
|
|
1302
|
-
lobbyManager.ConnectVoice(id, (result) =>
|
|
1303
|
-
{
|
|
1304
|
-
Console.WriteLine("Connected to voice!");
|
|
1305
|
-
});
|
|
1306
|
-
});
|
|
1307
|
-
```
|
|
1308
|
-
|
|
1309
|
-
## Example: Crossplayish
|
|
1310
|
-
|
|
1311
|
-
So, an explanation. Because the DLL that you ship with your game is a stub that calls out to the local Discord client for actual operations, the SDK does not necessarily care if the game was launched from Discord. As long as the player launching the game:
|
|
1312
|
-
|
|
1313
|
-
1. Has Discord installed
|
|
1314
|
-
2. Has a Discord account
|
|
1315
|
-
3. Has logged into Discord on their machine (whether or not Discord is open)
|
|
1316
|
-
|
|
1317
|
-
The SDK will function as if the game were launched from Discord and everything will work; if Discord is not currently launched, the SDK will launch it.
|
|
1318
|
-
|
|
1319
|
-
That means that if Player A is launching Your Amazing Game from Discord, and Player B is launching it from Other Cool But Not As Cool As Discord Game Store, as long as Player B meets the above criteria, both players can play with each other using Discord's lobbies + networking functions. If the SDK is not able to launch Discord for Player B—maybe they've never installed/used Discord before!—you'll get an error saying as much. We're not saying what you _should_ do, but hey, wouldn't this make a really neat in-game touchpoint for your players to join their friends on Discord, and maybe even join your game's [verified server](https://discord.com/verification)?
|
|
1320
|
-
|
|
1321
|
-
OK so this wasn't really a code example, but I think you get how this works.
|
|
1322
|
-
|
|
1323
|
-
## The API Way
|
|
1324
|
-
|
|
1325
|
-
Below are the API endpoints and the parameters they accept. If you choose to interface directly with the Discord API, you will need a "Bot token". This is a special authorization token with which your application can access Discord's HTTP API. Head on over to [your app's dashboard](https://discord.com/developers/), and hit the big "Add a Bot User" button. From there, mutter _abra kadabra_ and reveal the token. This token is used as an authorization header against our API like so:
|
|
1326
|
-
|
|
1327
|
-
```
|
|
1328
|
-
curl -x POST -h "Authorization: Bot <your token>" https://discord.com/api/some-route/that-does-a-thing
|
|
1329
|
-
```
|
|
1330
|
-
|
|
1331
|
-
> info
|
|
1332
|
-
> Make sure to prepend your token with "Bot"!
|
|
1333
|
-
|
|
1334
|
-
Here are the routes; they all expect JSON bodies. Also, hey, while you're here. You've got a bot token. You're looking at our API. You should check out all the other [awesome stuff](https://discord.com/developers/docs/intro) you can do with it!
|
|
1335
|
-
|
|
1336
|
-
### Create Lobby
|
|
1337
|
-
|
|
1338
|
-
`POST https://discord.com/api/v6/lobbies`
|
|
1339
|
-
|
|
1340
|
-
Creates a new lobby. Returns an object similar to the SDK `Lobby` struct, documented below.
|
|
1341
|
-
|
|
1342
|
-
To get a list of valid regions, call the [List Voice Regions](https://discord.com/developers/docs/resources/voice#list-voice-regions) endpoint.
|
|
1343
|
-
|
|
1344
|
-
###### Parameters
|
|
1345
|
-
|
|
1346
|
-
| name | type | description |
|
|
1347
|
-
| -------------- | --------- | ---------------------------------------------------------------------------------------------------- |
|
|
1348
|
-
| application_id | string | your application id |
|
|
1349
|
-
| type | LobbyType | the type of lobby |
|
|
1350
|
-
| metadata | dict | metadata for the lobby - key/value pairs with types `string` |
|
|
1351
|
-
| capacity | int | max lobby capacity with a default of 16 |
|
|
1352
|
-
| region | string | the region in which to make the lobby - defaults to the region of the requesting server's IP address |
|
|
1353
|
-
|
|
1354
|
-
###### Return Object
|
|
1355
|
-
|
|
1356
|
-
```json
|
|
1357
|
-
{
|
|
1358
|
-
"capacity": 10,
|
|
1359
|
-
"region": "us-west",
|
|
1360
|
-
"secret": "400316b221351324",
|
|
1361
|
-
"application_id": "299996444748734465",
|
|
1362
|
-
"metadata": {
|
|
1363
|
-
"a": "wow",
|
|
1364
|
-
"b": "some test metadata"
|
|
1365
|
-
},
|
|
1366
|
-
"type": 1,
|
|
1367
|
-
"id": "469317204969993265",
|
|
1368
|
-
"owner_id": "53908232599983680"
|
|
1369
|
-
}
|
|
1370
|
-
```
|
|
1371
|
-
|
|
1372
|
-
### Update Lobby
|
|
1373
|
-
|
|
1374
|
-
`PATCH https://discord.com/api/v6/lobbies/<lobby_id>`
|
|
1375
|
-
|
|
1376
|
-
Updates a lobby.
|
|
1377
|
-
|
|
1378
|
-
###### Parameters
|
|
1379
|
-
|
|
1380
|
-
| name | type | description |
|
|
1381
|
-
| -------- | --------- | ------------------------------------------------------------ |
|
|
1382
|
-
| type | LobbyType | the type of lobby |
|
|
1383
|
-
| metadata | dict | metadata for the lobby - key/value pairs with types `string` |
|
|
1384
|
-
| capacity | int | max lobby capacity with a default of 16 |
|
|
1385
|
-
|
|
1386
|
-
### Delete Lobby
|
|
1387
|
-
|
|
1388
|
-
`DELETE https://discord.com/api/v6/lobbies/<lobby_id>`
|
|
1389
|
-
|
|
1390
|
-
Deletes a lobby.
|
|
1391
|
-
|
|
1392
|
-
### Update Lobby Member
|
|
1393
|
-
|
|
1394
|
-
`PATCH https://discord.com/api/v6/lobbies/<lobby_id>/members/<user_id>`
|
|
1395
|
-
|
|
1396
|
-
Updates the metadata for a lobby member.
|
|
1397
|
-
|
|
1398
|
-
###### Parameters
|
|
1399
|
-
|
|
1400
|
-
| name | type | description |
|
|
1401
|
-
| -------- | ---- | ------------------------------------------------------------------- |
|
|
1402
|
-
| metadata | dict | metadata for the lobby member - key/value pairs with types `string` |
|
|
1403
|
-
|
|
1404
|
-
### Create Lobby Search
|
|
1405
|
-
|
|
1406
|
-
`POST https://discord.com/api/v6/lobbies/search`
|
|
1407
|
-
|
|
1408
|
-
Creates a lobby search for matchmaking around given criteria.
|
|
1409
|
-
|
|
1410
|
-
###### Parameters
|
|
1411
|
-
|
|
1412
|
-
| name | type | description |
|
|
1413
|
-
| -------------- | ----------------------------- | ---------------------------------------- |
|
|
1414
|
-
| application_id | string | your application id |
|
|
1415
|
-
| filter | array of SearchFilter objects | the filter to check against |
|
|
1416
|
-
| sort | array of SearchSort objects | how to sort the results |
|
|
1417
|
-
| limit | int | limit of lobbies returned, default of 25 |
|
|
1418
|
-
|
|
1419
|
-
###### SearchFilter Object
|
|
1420
|
-
|
|
1421
|
-
| name | type | description |
|
|
1422
|
-
| ---------- | ---------------- | ------------------------------------------------- |
|
|
1423
|
-
| key | string | the metadata key to search |
|
|
1424
|
-
| value | string | the value of the metadata key to validate against |
|
|
1425
|
-
| cast | SearchCast | the type to cast `value` as |
|
|
1426
|
-
| comparison | SearchComparison | how to compare the metadata values |
|
|
1427
|
-
|
|
1428
|
-
###### SearchComparison Types
|
|
1429
|
-
|
|
1430
|
-
| name | value |
|
|
1431
|
-
| ------------------------ | ----- |
|
|
1432
|
-
| EQUAL_TO_OR_LESS_THAN | -2 |
|
|
1433
|
-
| LESS_THAN | -1 |
|
|
1434
|
-
| EQUAL | 0 |
|
|
1435
|
-
| EQUAL_TO_OR_GREATER_THAN | 1 |
|
|
1436
|
-
| GREATER_THAN | 2 |
|
|
1437
|
-
| NOT_EQUAL | 3 |
|
|
1438
|
-
|
|
1439
|
-
###### SearchSort Object
|
|
1440
|
-
|
|
1441
|
-
| name | type | description |
|
|
1442
|
-
| ---------- | ---------- | ----------------------------------------------------------------------- |
|
|
1443
|
-
| key | string | the metadata key on which to sort lobbies that meet the search criteria |
|
|
1444
|
-
| cast | SearchCast | the type to cast `value` as |
|
|
1445
|
-
| near_value | string | the value around which to sort the key |
|
|
1446
|
-
|
|
1447
|
-
###### SearchCast Types
|
|
1448
|
-
|
|
1449
|
-
| name | value |
|
|
1450
|
-
| ------ | ----- |
|
|
1451
|
-
| STRING | 1 |
|
|
1452
|
-
| NUMBER | 2 |
|
|
1453
|
-
|
|
1454
|
-
### Send Lobby Data
|
|
1455
|
-
|
|
1456
|
-
`POST https://discord.com/api/v6/lobbies/<lobby_id>/send`
|
|
1457
|
-
|
|
1458
|
-
Sends a message to the lobby, fanning it out to other lobby members.
|
|
1459
|
-
|
|
1460
|
-
This endpoints accepts a UTF8 string. If your message is already a string, you're good to go! If you want to send binary, you can send it to this endpoint as a base64 encoded data uri.
|
|
1461
|
-
|
|
1462
|
-
###### Parameters
|
|
1463
|
-
|
|
1464
|
-
| name | type | description |
|
|
1465
|
-
| ---- | ------ | ------------------------------------------- |
|
|
1466
|
-
| data | string | a message to be sent to other lobby members |
|
|
1467
|
-
|
|
1468
|
-
## Integrated Networking
|
|
1469
|
-
|
|
1470
|
-
Discord lobbies have the option of being used with a wrapped networking layer, allowing you to start sending packets quickly and easily without needing to do state management around routes, peer IDs, member metadata, and the like.
|
|
1471
|
-
|
|
1472
|
-
This layer allows you to easily connect to the network and open channels to all lobby members with one function call. You can then send network messages to users by their user ID, easily retrieved via lobby methods.
|
|
1473
|
-
|
|
1474
|
-
We take care of all the route updating for you, so you can get up and running quickly and easily. If you'd like to see how the lower level networking functionality works, or want to try it yourself so you can tweak it to your liking, check out [Networking](#DOCS_GAME_SDK_NETWORKING/);
|
|
1475
|
-
|
|
1476
|
-
## ConnectNetwork
|
|
1477
|
-
|
|
1478
|
-
Connects to the networking layer for the given lobby ID. Call this when connecting to the lobby.
|
|
1479
|
-
|
|
1480
|
-
Returns `void`.
|
|
1481
|
-
|
|
1482
|
-
###### Parameters
|
|
1483
|
-
|
|
1484
|
-
| name | type | description |
|
|
1485
|
-
| ------- | ----- | ------------------------------ |
|
|
1486
|
-
| lobbyId | Int64 | the ID of the lobby you are in |
|
|
1487
|
-
|
|
1488
|
-
###### Example
|
|
1489
|
-
|
|
1490
|
-
```cs
|
|
1491
|
-
lobbyManager.ConnectLobby(lobbyId, (result, lobby) =>
|
|
1492
|
-
{
|
|
1493
|
-
lobbyManager.ConnectNetwork(lobby.Id);
|
|
1494
|
-
});
|
|
1495
|
-
```
|
|
1496
|
-
|
|
1497
|
-
## DisconnectNetwork
|
|
1498
|
-
|
|
1499
|
-
Disconnects from the networking layer for the given lobby ID.
|
|
1500
|
-
|
|
1501
|
-
Returns `void`.
|
|
1502
|
-
|
|
1503
|
-
###### Parameters
|
|
1504
|
-
|
|
1505
|
-
| name | type | description |
|
|
1506
|
-
| ------- | ----- | ------------------------------ |
|
|
1507
|
-
| lobbyId | Int64 | the ID of the lobby you are in |
|
|
1508
|
-
|
|
1509
|
-
###### Example
|
|
1510
|
-
|
|
1511
|
-
```cs
|
|
1512
|
-
lobbyManager.DisconnectNetwork(lobby.Id);
|
|
1513
|
-
```
|
|
1514
|
-
|
|
1515
|
-
## FlushNetwork
|
|
1516
|
-
|
|
1517
|
-
Flushes the network. Call this when you're done sending messages. In Unity, this should be in `LateUpdate()`.
|
|
1518
|
-
|
|
1519
|
-
Returns `void`.
|
|
1520
|
-
|
|
1521
|
-
###### Parameters
|
|
1522
|
-
|
|
1523
|
-
None
|
|
1524
|
-
|
|
1525
|
-
###### Example
|
|
1526
|
-
|
|
1527
|
-
```cs
|
|
1528
|
-
void LateUpdate()
|
|
1529
|
-
{
|
|
1530
|
-
var lobbyManager = discord.GetLobbyManager();
|
|
1531
|
-
lobbyManager.FlushNetwork();
|
|
1532
|
-
}
|
|
1533
|
-
```
|
|
1534
|
-
|
|
1535
|
-
## OpenNetworkChannel
|
|
1536
|
-
|
|
1537
|
-
Opens a network channel to all users in a lobby on the given channel number. No need to iterate over everyone!
|
|
1538
|
-
|
|
1539
|
-
Returns `void`.
|
|
1540
|
-
|
|
1541
|
-
###### Parameters
|
|
1542
|
-
|
|
1543
|
-
| name | type | description |
|
|
1544
|
-
| --------- | ----- | ---------------------------------------------------- |
|
|
1545
|
-
| lobbyId | Int64 | the ID of the lobby you are in |
|
|
1546
|
-
| channelId | byte | the channel on which to connect |
|
|
1547
|
-
| reliable | bool | whether the channel should be unreliable or reliable |
|
|
1548
|
-
|
|
1549
|
-
###### Example
|
|
1550
|
-
|
|
1551
|
-
```cs
|
|
1552
|
-
var lobbyManager = discord.GetLobbyManager();
|
|
1553
|
-
lobbyManager.ConnectLobby(lobbyId, (result, lobby) =>
|
|
1554
|
-
{
|
|
1555
|
-
lobbyManager.ConnectNetwork(lobby.Id);
|
|
1556
|
-
lobbyManager.OpenNetworkChannel(lobby.Id, 0, true);
|
|
1557
|
-
});
|
|
1558
|
-
```
|
|
1559
|
-
|
|
1560
|
-
## SendNetworkMessage
|
|
1561
|
-
|
|
1562
|
-
Sends a network message to the given user ID that is a member of the given lobby ID over the given channel ID.
|
|
1563
|
-
|
|
1564
|
-
Returns `void`.
|
|
1565
|
-
|
|
1566
|
-
###### Parameters
|
|
1567
|
-
|
|
1568
|
-
| name | type | description |
|
|
1569
|
-
| --------- | ------ | --------------------------------------- |
|
|
1570
|
-
| lobbyId | Int64 | the ID of the lobby you are in |
|
|
1571
|
-
| userId | Int64 | the ID of the user to send a message to |
|
|
1572
|
-
| channelId | byte | the channel on which to connect |
|
|
1573
|
-
| data | byte[] | the message to send |
|
|
1574
|
-
|
|
1575
|
-
###### Example
|
|
1576
|
-
|
|
1577
|
-
```cs
|
|
1578
|
-
var lobbyManager = discord.GetLobbyManager();
|
|
1579
|
-
lobbyManager.ConnectLobby(lobbyId, (result, lobby) =>
|
|
1580
|
-
{
|
|
1581
|
-
lobbyManager.ConnectNetwork(lobby.Id);
|
|
1582
|
-
lobbyManager.OpenNetworkChannel(lobby.Id, 0, true);
|
|
1583
|
-
for (int i = 0; i < lobbyManager.MemberCount(); i++)
|
|
1584
|
-
{
|
|
1585
|
-
var userId = lobbyManager.GetMemberUserId(i);
|
|
1586
|
-
lobbyManager.SendNetworkMessage(lobby.Id, userId, 0, System.Text.Encoding.UTF8.GetBytes("Hello!"));
|
|
1587
|
-
}
|
|
1588
|
-
});
|
|
1589
|
-
```
|
|
1590
|
-
|
|
1591
|
-
## OnNetworkMessage
|
|
1592
|
-
|
|
1593
|
-
Fires when the user receives a message from the lobby's networking layer.
|
|
1594
|
-
|
|
1595
|
-
###### Parameters
|
|
1596
|
-
|
|
1597
|
-
| name | type | description |
|
|
1598
|
-
| --------- | ------ | --------------------------------------- |
|
|
1599
|
-
| lobbyId | Int64 | the ID of the lobby you are in |
|
|
1600
|
-
| userId | Int64 | the ID of the user who sent the message |
|
|
1601
|
-
| channelId | byte | the channel the message was sent on |
|
|
1602
|
-
| data | byte[] | the message |
|
|
1603
|
-
|
|
1604
|
-
## Example: Networking the Easy Way
|
|
1605
|
-
|
|
1606
|
-
```cs
|
|
1607
|
-
// We can create a helper method to easily connect to the networking layer of the lobby
|
|
1608
|
-
public void InitNetworking(Int64 lobbyId)
|
|
1609
|
-
{
|
|
1610
|
-
// First, connect to the lobby network layer
|
|
1611
|
-
var lobbyManager = discord.GetLobbyManager();
|
|
1612
|
-
lobbyManager.ConnectNetwork(lobbyId);
|
|
1613
|
-
|
|
1614
|
-
// Next, deterministically open our channels
|
|
1615
|
-
// Reliable on 0, unreliable on 1
|
|
1616
|
-
lobbyManager.OpenNetworkChannel(lobbyId, 0, true);
|
|
1617
|
-
lobbyManager.OpenNetworkChannel(lobbyId, 1, false);
|
|
1618
|
-
|
|
1619
|
-
// We're ready to go!
|
|
1620
|
-
}
|
|
1621
|
-
|
|
1622
|
-
// Let's say we got a game invite from Rich Presence
|
|
1623
|
-
activityManager.OnActivityJoin += secret =>
|
|
1624
|
-
{
|
|
1625
|
-
var lobbyManager = discord.GetLobbyManager();
|
|
1626
|
-
lobbyManager.ConnectLobbyWithActivitySecret(secret, (Discord.Result result, ref Discord.Lobby lobby) =>
|
|
1627
|
-
{
|
|
1628
|
-
// Connect to networking
|
|
1629
|
-
InitNetworking(lobby.Id);
|
|
1630
|
-
|
|
1631
|
-
// Say hello!
|
|
1632
|
-
for (int i = 0; i < lobbyManager.MemberCount(); i++)
|
|
1633
|
-
{
|
|
1634
|
-
var userId = lobbyManager.GetMemberUserId(i);
|
|
1635
|
-
lobbyManager.SendNetworkMessage(lobby.Id, userId, 0, System.Text.Encoding.UTF8.GetBytes("Hello!"));
|
|
1636
|
-
}
|
|
1637
|
-
});
|
|
1638
|
-
}
|
|
1639
|
-
```
|