@my-swu/simulator-client / LobbySession
Interface: LobbySession
Defined in: packages/ts-sdk/src/resources/lobby-types.ts:398
Example:
import { createSimulatorClient } from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
baseUrl: 'http://127.0.0.1:4000',
})
// Keep playerToken private; it authenticates this lobby player.
const lobbySession = simulatorClient.lobbies.createSession({
lobbyId: 'lobby_123',
playerToken: 'player_token_123',
})
console.log(lobbySession)Properties
__v_skip
Example:
import { createSimulatorClient } from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
baseUrl: 'http://127.0.0.1:4000',
})
// Keep playerToken private; it authenticates this lobby player.
const lobbySession = simulatorClient.lobbies.createSession({
lobbyId: 'lobby_123',
playerToken: 'player_token_123',
})
const { __v_skip } = lobbySession
console.log(__v_skip)
readonly__v_skip:true
Defined in: packages/ts-sdk/src/resources/lobby-types.ts:399
close
Example:
import { createSimulatorClient } from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
baseUrl: 'http://127.0.0.1:4000',
})
// Keep playerToken private; it authenticates this lobby player.
const lobbySession = simulatorClient.lobbies.createSession({
lobbyId: 'lobby_123',
playerToken: 'player_token_123',
})
const { close } = lobbySession
console.log(close)close: () =>
void
Defined in: packages/ts-sdk/src/resources/lobby-types.ts:408
Returns
void
closedReason?
Example:
import { createSimulatorClient } from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
baseUrl: 'http://127.0.0.1:4000',
})
// Keep playerToken private; it authenticates this lobby player.
const lobbySession = simulatorClient.lobbies.createSession({
lobbyId: 'lobby_123',
playerToken: 'player_token_123',
})
const { closedReason } = lobbySession
console.log(closedReason)
readonlyoptionalclosedReason?:LobbyClosedReason
Defined in: packages/ts-sdk/src/resources/lobby-types.ts:407
Reason from the closed message, once the lobby closed.
connect
Example:
import { createSimulatorClient } from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
baseUrl: 'http://127.0.0.1:4000',
})
// Keep playerToken private; it authenticates this lobby player.
const lobbySession = simulatorClient.lobbies.createSession({
lobbyId: 'lobby_123',
playerToken: 'player_token_123',
})
const { connect } = lobbySession
console.log(connect)connect: () =>
Promise<LobbySession>
Defined in: packages/ts-sdk/src/resources/lobby-types.ts:409
Returns
Promise<LobbySession>
connectionState
Example:
import { createSimulatorClient } from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
baseUrl: 'http://127.0.0.1:4000',
})
// Keep playerToken private; it authenticates this lobby player.
const lobbySession = simulatorClient.lobbies.createSession({
lobbyId: 'lobby_123',
playerToken: 'player_token_123',
})
const { connectionState } = lobbySession
console.log(connectionState)
readonlyconnectionState:ConnectionState
Defined in: packages/ts-sdk/src/resources/lobby-types.ts:400
errorMessages
Example:
import { createSimulatorClient } from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
baseUrl: 'http://127.0.0.1:4000',
})
// Keep playerToken private; it authenticates this lobby player.
const lobbySession = simulatorClient.lobbies.createSession({
lobbyId: 'lobby_123',
playerToken: 'player_token_123',
})
const { errorMessages } = lobbySession
console.log(errorMessages)
readonlyerrorMessages: readonlystring[]
Defined in: packages/ts-sdk/src/resources/lobby-types.ts:401
errors
Example:
import { createSimulatorClient } from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
baseUrl: 'http://127.0.0.1:4000',
})
// Keep playerToken private; it authenticates this lobby player.
const lobbySession = simulatorClient.lobbies.createSession({
lobbyId: 'lobby_123',
playerToken: 'player_token_123',
})
const { errors } = lobbySession
console.log(errors)
readonlyerrors: readonlyErrorPayload[]
Defined in: packages/ts-sdk/src/resources/lobby-types.ts:402
on
Example:
import { createSimulatorClient } from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
baseUrl: 'http://127.0.0.1:4000',
})
// Keep playerToken private; it authenticates this lobby player.
const lobbySession = simulatorClient.lobbies.createSession({
lobbyId: 'lobby_123',
playerToken: 'player_token_123',
})
const { on } = lobbySession
console.log(on)on: <
TKey>(event,listener) => () =>void
Defined in: packages/ts-sdk/src/resources/lobby-types.ts:410
Type Parameters
TKey
TKey extends keyof LobbySessionEvents
Parameters
event
TKey
listener
(value) => void
Returns
() => void
ping
Example:
import { createSimulatorClient } from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
baseUrl: 'http://127.0.0.1:4000',
})
// Keep playerToken private; it authenticates this lobby player.
const lobbySession = simulatorClient.lobbies.createSession({
lobbyId: 'lobby_123',
playerToken: 'player_token_123',
})
const { ping } = lobbySession
console.log(ping)ping: (
nonce?) =>void
Defined in: packages/ts-sdk/src/resources/lobby-types.ts:414
Parameters
nonce?
string
Returns
void
privateView?
Example:
import { createSimulatorClient } from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
baseUrl: 'http://127.0.0.1:4000',
})
// Keep playerToken private; it authenticates this lobby player.
const lobbySession = simulatorClient.lobbies.createSession({
lobbyId: 'lobby_123',
playerToken: 'player_token_123',
})
const { privateView } = lobbySession
console.log(privateView)
readonlyoptionalprivateView?:LobbyPrivateView
Defined in: packages/ts-sdk/src/resources/lobby-types.ts:405
Latest private view pushed over this socket, if any.
snapshot
Example:
import { createSimulatorClient } from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
baseUrl: 'http://127.0.0.1:4000',
})
// Keep playerToken private; it authenticates this lobby player.
const lobbySession = simulatorClient.lobbies.createSession({
lobbyId: 'lobby_123',
playerToken: 'player_token_123',
})
const { snapshot: matchSnapshot } = lobbySession
console.log(matchSnapshot)
readonlysnapshot:LobbySnapshot|undefined
Defined in: packages/ts-sdk/src/resources/lobby-types.ts:403
