@indiegems/gem-web-sdk 10.1.0 → 10.2.0

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.
@@ -1,6 +1,6 @@
1
1
  # The server surface — API reference
2
2
 
3
- Generated from `@indiegems/gem-web-sdk/sdk` v10.1.0, the version of the package this file ships in. Every symbol below carries an explicit anchor, its `anchor` in `reference.json` beside this file.
3
+ Generated from `@indiegems/gem-web-sdk/sdk` v10.2.0, the version of the package this file ships in. Every symbol below carries an explicit anchor, its `anchor` in `reference.json` beside this file.
4
4
 
5
5
  `@indiegems/gem-web-sdk/sdk` is the one import a game writes, wherever its code runs. `@indiegems/gem-web-sdk/server` exports exactly the symbols on this page and nothing else, for a build that wants only this half.
6
6
 
@@ -2244,6 +2244,38 @@ not have to keep reaching back to the host object.
2244
2244
  These are also the ids bound into every call `api` makes, which is why a
2245
2245
  bundle never types a game id and cannot name another game's.
2246
2246
 
2247
+ <a id="matchbackfillstate"></a>
2248
+
2249
+ ## MatchBackfillState
2250
+
2251
+ ```ts
2252
+ interface MatchBackfillState
2253
+ ```
2254
+
2255
+ Whether this match is being topped up from the matchmaking queue, as the
2256
+ platform now has it.
2257
+
2258
+ <a id="matchplayerreport"></a>
2259
+
2260
+ ## MatchPlayerReport
2261
+
2262
+ ```ts
2263
+ interface MatchPlayerReport
2264
+ ```
2265
+
2266
+ What your server says about one player of its match, for
2267
+ [GemServer.match](#gemserver-match)'s `reportPlayers`.
2268
+
2269
+ <a id="matchplayerreportresult"></a>
2270
+
2271
+ ## MatchPlayerReportResult
2272
+
2273
+ ```ts
2274
+ interface MatchPlayerReportResult
2275
+ ```
2276
+
2277
+ What a report did for one player, in the order you reported them.
2278
+
2247
2279
  <a id="gemserveroptions"></a>
2248
2280
 
2249
2281
  ## GemServerOptions
@@ -3004,6 +3036,72 @@ The room this match came from, when there is one.
3004
3036
  CHECK IT BEFORE USING IT. It is absent on older platform images, which is
3005
3037
  also why [GemServer.room](#gemserver-room) can be absent — the two go together.
3006
3038
 
3039
+ <a id="matchplayerreport-playerid"></a>
3040
+
3041
+ ## MatchPlayerReport.playerId
3042
+
3043
+ ```ts
3044
+ readonly playerId: string
3045
+ ```
3046
+
3047
+ The player. Take it from `join()`, `leave()` or the room, never from a client.
3048
+
3049
+ <a id="matchplayerreport-state"></a>
3050
+
3051
+ ## MatchPlayerReport.state
3052
+
3053
+ ```ts
3054
+ readonly state: "connected" | "no_show" | "left"
3055
+ ```
3056
+
3057
+ - `connected` — the player has connected to this server.
3058
+ - `no_show` — the player was given a seat and never connected.
3059
+ - `left` — the player was in the match and is gone FOR GOOD.
3060
+
3061
+ The last two remove the player from the room, which frees the seat.
3062
+
3063
+ <a id="matchplayerreportresult-playerid"></a>
3064
+
3065
+ ## MatchPlayerReportResult.playerId
3066
+
3067
+ ```ts
3068
+ readonly playerId: string
3069
+ ```
3070
+
3071
+ The player this result is for.
3072
+
3073
+ <a id="matchplayerreportresult-outcome"></a>
3074
+
3075
+ ## MatchPlayerReportResult.outcome
3076
+
3077
+ ```ts
3078
+ readonly outcome: "recorded" | "removed" | "not_a_member" | string & object
3079
+ ```
3080
+
3081
+ - `recorded` — `connected` was noted.
3082
+ - `removed` — the player was taken out of the room.
3083
+ - `not_a_member` — the player is not in this match's room; nothing changed.
3084
+
3085
+ <a id="matchbackfillstate-open"></a>
3086
+
3087
+ ## MatchBackfillState.open
3088
+
3089
+ ```ts
3090
+ readonly open: boolean
3091
+ ```
3092
+
3093
+ Whether the match is taking players from the queue.
3094
+
3095
+ <a id="matchbackfillstate-seats"></a>
3096
+
3097
+ ## MatchBackfillState.seats
3098
+
3099
+ ```ts
3100
+ readonly seats: number | null
3101
+ ```
3102
+
3103
+ The most players still wanted, or `null` for every open seat.
3104
+
3007
3105
  <a id="gemserver-identity"></a>
3008
3106
 
3009
3107
  ## GemServer.identity
@@ -3047,7 +3145,7 @@ See [ServerApi](#serverapi).
3047
3145
  ## GemServer.match
3048
3146
 
3049
3147
  ```ts
3050
- readonly match: { end: null }
3148
+ readonly match: { end: null; setBackfill: null; reportPlayers: null }
3051
3149
  ```
3052
3150
 
3053
3151
  Ending the match.
@@ -3082,6 +3180,77 @@ Tell the platform this match is finished.
3082
3180
  **Throws.** When the platform image running this server predates
3083
3181
  `host.endMatch`, so the match cannot be ended from here.
3084
3182
 
3183
+ <a id="gemserver-match-setbackfill"></a>
3184
+
3185
+ ## GemServer.match.setBackfill
3186
+
3187
+ ```ts
3188
+ setBackfill(options: { open: boolean; seats?: number }, signal?: AbortSignal): Promise<MatchBackfillState>
3189
+ ```
3190
+
3191
+ Stop, or restart, the platform topping this match up from the
3192
+ matchmaking queue.
3193
+
3194
+ A match the platform matchmade from a room type with backfill turned on
3195
+ takes waiting players into its open seats from the moment it starts.
3196
+ This is how your server takes control of that: close it once joining
3197
+ late no longer makes sense — the last round, a boss fight — and open it
3198
+ again if it does.
3199
+
3200
+ Closing removes nobody, and a player already on the way in still
3201
+ arrives. The setting lasts for the match.
3202
+
3203
+ | Parameter | Type | Description |
3204
+ | --- | --- | --- |
3205
+ | `options` | `{ open: boolean; seats?: number }` | `open` — whether to take players. `seats` — with
3206
+ `open: true`, the most players still wanted; it counts down as seats
3207
+ fill. Omit it for every open seat. |
3208
+ | `signal` | `AbortSignal` | Cancels the request. |
3209
+
3210
+ **Throws.** A `GemApiError` with code `backfill_not_enabled` when this match
3211
+ is not one the platform tops up: its room type has no backfill, or the
3212
+ room was not matchmade.
3213
+
3214
+ ```js
3215
+ // Nobody new once the final round starts.
3216
+ await gem.match.setBackfill({ open: false });
3217
+ ```
3218
+
3219
+ <a id="gemserver-match-reportplayers"></a>
3220
+
3221
+ ## GemServer.match.reportPlayers
3222
+
3223
+ ```ts
3224
+ reportPlayers(reports: readonly MatchPlayerReport[], signal?: AbortSignal): Promise<MatchPlayerReportResult[]>
3225
+ ```
3226
+
3227
+ Tell the platform which players have connected, never arrived, or left.
3228
+
3229
+ `no_show` and `left` REMOVE THE PLAYER FROM THE ROOM, which frees the
3230
+ seat — for the queue, when the match is being topped up. Report `left`
3231
+ only for a player who is gone for good: reconnecting does not put a
3232
+ removed player back, they have to join again.
3233
+
3234
+ YOU DO NOT REPORT `connected` YOURSELF in a bundle built with
3235
+ [defineServer](#defineserver): it reports each player as they join. That report is
3236
+ what gives a seat the platform filled from the queue a time limit — a
3237
+ player who is seated and never connects is removed, and the seat goes to
3238
+ the next one waiting.
3239
+
3240
+ | Parameter | Type | Description |
3241
+ | --- | --- | --- |
3242
+ | `reports` | `readonly MatchPlayerReport[]` | 1 to 32 players. |
3243
+ | `signal` | `AbortSignal` | Cancels the request. |
3244
+
3245
+ **Returns.** One result per report, in the same order.
3246
+
3247
+ ```js
3248
+ leave(playerId) {
3249
+ // This game does not let a player back in once they quit.
3250
+ void gem.match.reportPlayers([{ playerId, state: 'left' }]);
3251
+ }
3252
+ ```
3253
+
3085
3254
  <a id="gemserver-analytics"></a>
3086
3255
 
3087
3256
  ## GemServer.analytics
@@ -3629,7 +3798,7 @@ Disconnect a player. `reason` is shown to them and recorded in the logs.
3629
3798
  ## GemServerHost.endMatch
3630
3799
 
3631
3800
  ```ts
3632
- endMatch(): Promise<"ok" | "already_ended" | "refused" | "failed" | string & object>
3801
+ endMatch(): Promise<string & object | "ok" | "already_ended" | "refused" | "failed">
3633
3802
  ```
3634
3803
 
3635
3804
  Ask the platform half to end this match, with the allocation's own proof.
@@ -4070,7 +4239,7 @@ See [ServerApi](#serverapi).
4070
4239
  ## GemMatchServer.match
4071
4240
 
4072
4241
  ```ts
4073
- readonly match: { end: null }
4242
+ readonly match: { end: null; setBackfill: null; reportPlayers: null }
4074
4243
  ```
4075
4244
 
4076
4245
  Ending the match.
@@ -4105,6 +4274,77 @@ Tell the platform this match is finished.
4105
4274
  **Throws.** When the platform image running this server predates
4106
4275
  `host.endMatch`, so the match cannot be ended from here.
4107
4276
 
4277
+ <a id="gemmatchserver-match-setbackfill"></a>
4278
+
4279
+ ## GemMatchServer.match.setBackfill
4280
+
4281
+ ```ts
4282
+ setBackfill(options: { open: boolean; seats?: number }, signal?: AbortSignal): Promise<MatchBackfillState>
4283
+ ```
4284
+
4285
+ Stop, or restart, the platform topping this match up from the
4286
+ matchmaking queue.
4287
+
4288
+ A match the platform matchmade from a room type with backfill turned on
4289
+ takes waiting players into its open seats from the moment it starts.
4290
+ This is how your server takes control of that: close it once joining
4291
+ late no longer makes sense — the last round, a boss fight — and open it
4292
+ again if it does.
4293
+
4294
+ Closing removes nobody, and a player already on the way in still
4295
+ arrives. The setting lasts for the match.
4296
+
4297
+ | Parameter | Type | Description |
4298
+ | --- | --- | --- |
4299
+ | `options` | `{ open: boolean; seats?: number }` | `open` — whether to take players. `seats` — with
4300
+ `open: true`, the most players still wanted; it counts down as seats
4301
+ fill. Omit it for every open seat. |
4302
+ | `signal` | `AbortSignal` | Cancels the request. |
4303
+
4304
+ **Throws.** A `GemApiError` with code `backfill_not_enabled` when this match
4305
+ is not one the platform tops up: its room type has no backfill, or the
4306
+ room was not matchmade.
4307
+
4308
+ ```js
4309
+ // Nobody new once the final round starts.
4310
+ await gem.match.setBackfill({ open: false });
4311
+ ```
4312
+
4313
+ <a id="gemmatchserver-match-reportplayers"></a>
4314
+
4315
+ ## GemMatchServer.match.reportPlayers
4316
+
4317
+ ```ts
4318
+ reportPlayers(reports: readonly MatchPlayerReport[], signal?: AbortSignal): Promise<MatchPlayerReportResult[]>
4319
+ ```
4320
+
4321
+ Tell the platform which players have connected, never arrived, or left.
4322
+
4323
+ `no_show` and `left` REMOVE THE PLAYER FROM THE ROOM, which frees the
4324
+ seat — for the queue, when the match is being topped up. Report `left`
4325
+ only for a player who is gone for good: reconnecting does not put a
4326
+ removed player back, they have to join again.
4327
+
4328
+ YOU DO NOT REPORT `connected` YOURSELF in a bundle built with
4329
+ [defineServer](#defineserver): it reports each player as they join. That report is
4330
+ what gives a seat the platform filled from the queue a time limit — a
4331
+ player who is seated and never connects is removed, and the seat goes to
4332
+ the next one waiting.
4333
+
4334
+ | Parameter | Type | Description |
4335
+ | --- | --- | --- |
4336
+ | `reports` | `readonly MatchPlayerReport[]` | 1 to 32 players. |
4337
+ | `signal` | `AbortSignal` | Cancels the request. |
4338
+
4339
+ **Returns.** One result per report, in the same order.
4340
+
4341
+ ```js
4342
+ leave(playerId) {
4343
+ // This game does not let a player back in once they quit.
4344
+ void gem.match.reportPlayers([{ playerId, state: 'left' }]);
4345
+ }
4346
+ ```
4347
+
4108
4348
  <a id="gemmatchserver-analytics"></a>
4109
4349
 
4110
4350
  ## GemMatchServer.analytics