Skip to content

@my-swu/simulator-client


@my-swu/simulator-client / LobbySession

Interface: LobbySession ​

Defined in: packages/ts-sdk/src/resources/lobby-types.ts:398

Example:

ts
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:

ts
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:

ts
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:

ts
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)

readonly optional closedReason?: LobbyClosedReason

Defined in: packages/ts-sdk/src/resources/lobby-types.ts:407

Reason from the closed message, once the lobby closed.


connect ​

Example:

ts
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:

ts
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)

readonly connectionState: ConnectionState

Defined in: packages/ts-sdk/src/resources/lobby-types.ts:400


errorMessages ​

Example:

ts
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)

readonly errorMessages: readonly string[]

Defined in: packages/ts-sdk/src/resources/lobby-types.ts:401


errors ​

Example:

ts
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)

readonly errors: readonly ErrorPayload[]

Defined in: packages/ts-sdk/src/resources/lobby-types.ts:402


on ​

Example:

ts
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:

ts
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:

ts
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)

readonly optional privateView?: LobbyPrivateView

Defined in: packages/ts-sdk/src/resources/lobby-types.ts:405

Latest private view pushed over this socket, if any.


snapshot ​

Example:

ts
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)

readonly snapshot: LobbySnapshot | undefined

Defined in: packages/ts-sdk/src/resources/lobby-types.ts:403

Released under the MIT License.