@my-swu/simulator-client / SessionResource
Interface: SessionResource
Defined in: packages/ts-sdk/src/resources/session.ts:32
Session resource for creating SDK-owned match sessions.
A MatchSession stores private access, owns one live socket at a time, and keeps renderable token-free state for UI consumers.
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',
})
// Seed with private access when you already have it.
const hostAccess = { matchId: 'match_123', seatToken: 'seat_token_123' }
const matchSession = simulatorClient.session.create(hostAccess)
console.log(matchSession.connectionState)Example
ts
import { createSimulatorClient } from '@my-swu/simulator-client'
const simulatorClient = createSimulatorClient({
baseUrl: 'http://127.0.0.1:4000',
})
const hostAccess = { matchId: 'match_123', seatToken: 'seat_token_123' }
const matchSession = simulatorClient.session.create(hostAccess)
console.log(matchSession.connectionState)See
https://simulator-sdk.my-swu.com/guide/match-session
Methods
create()
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',
})
// Create an idle session or seed it with private match access.
const matchSession = simulatorClient.session.create({
matchId: 'match_123',
seatToken: 'seat_token_123',
})create(
access?,options?):MatchSession
Defined in: packages/ts-sdk/src/resources/session.ts:54
Creates one idle or access-seeded match session.
Seed with access when you already created or joined a match. Omit access when the session will call createMatch() or joinMatch() itself.
Parameters
access?
options?
Returns
Example
ts
import { createSimulatorClient } from '@my-swu/simulator-client'
const simulatorClient = createSimulatorClient({
baseUrl: 'http://127.0.0.1:4000',
})
const hostAccess = { matchId: 'match_123', seatToken: 'seat_token_123' }
const matchSession = simulatorClient.session.create(hostAccess)
await matchSession.connect()See
https://simulator-sdk.my-swu.com/guide/match-session#creating-a-session
