({
runtimeGame,
gameId,
}: {
runtimeGame: gdjs.RuntimeGame;
gameId: string;
})
| 258 | }); |
| 259 | |
| 260 | const getLobbiesWindowUrl = ({ |
| 261 | runtimeGame, |
| 262 | gameId, |
| 263 | }: { |
| 264 | runtimeGame: gdjs.RuntimeGame; |
| 265 | gameId: string; |
| 266 | }) => { |
| 267 | // Uncomment to test the case of a failing loading: |
| 268 | // return 'https://gd.games.wronglink'; |
| 269 | |
| 270 | const baseUrl = 'https://gd.games'; |
| 271 | // Uncomment to test locally: |
| 272 | // const baseUrl = 'http://localhost:4000'; |
| 273 | |
| 274 | const url = new URL( |
| 275 | `${baseUrl}/games/${gameId}/lobbies${_lobbyId ? `/${_lobbyId}` : ''}` |
| 276 | ); |
| 277 | url.searchParams.set( |
| 278 | 'gameVersion', |
| 279 | runtimeGame.getGameData().properties.version |
| 280 | ); |
| 281 | if (runtimeGame.getAdditionalOptions().nativeMobileApp) { |
| 282 | url.searchParams.set('nativeMobileApp', 'true'); |
| 283 | } |
| 284 | url.searchParams.set( |
| 285 | 'isPreview', |
| 286 | runtimeGame.isPreview() ? 'true' : 'false' |
| 287 | ); |
| 288 | if (isUsingGDevelopDevelopmentEnvironment) { |
| 289 | url.searchParams.set('dev', 'true'); |
| 290 | } |
| 291 | if (_connectionId) { |
| 292 | url.searchParams.set('connectionId', _connectionId); |
| 293 | } |
| 294 | if (playerNumber) { |
| 295 | url.searchParams.set('positionInLobby', playerNumber.toString()); |
| 296 | } |
| 297 | const playerId = gdjs.playerAuthentication.getUserId(); |
| 298 | if (playerId) { |
| 299 | url.searchParams.set('playerId', playerId); |
| 300 | } |
| 301 | const playerToken = gdjs.playerAuthentication.getUserToken(); |
| 302 | if (playerToken) { |
| 303 | url.searchParams.set('playerToken', playerToken); |
| 304 | } |
| 305 | const platformInfo = runtimeGame.getPlatformInfo(); |
| 306 | url.searchParams.set( |
| 307 | 'scm', |
| 308 | platformInfo.supportedCompressionMethods.join(',') |
| 309 | ); |
| 310 | // Increment this value when a new feature is introduced so we can |
| 311 | // adapt the interface of the lobbies. |
| 312 | url.searchParams.set('multiplayerVersion', '2'); |
| 313 | |
| 314 | return url.toString(); |
| 315 | }; |
| 316 | |
| 317 | export const setObjectsSynchronizationRate = (rate: number) => { |
no test coverage detected