Skip to content

@my-swu/simulator-client


@my-swu/simulator-client / TournamentRoomSessionEvents

Interface: TournamentRoomSessionEvents ​

Defined in: packages/ts-sdk/src/resources/tournament-room-types.ts:60

Events emitted by a tournament room websocket session.

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 room player.
const tournamentRoomSession = simulatorClient.tournamentRooms.createSession({
  roomId: 'room_123',
  playerToken: 'player_token_123',
})

// Listener payloads are typed by the event name.
const stopListening = tournamentRoomSession.on('change', changePayload => {
  console.log(changePayload)
})

stopListening()

Properties ​

change ​

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 room player.
const tournamentRoomSession = simulatorClient.tournamentRooms.createSession({
  roomId: 'room_123',
  playerToken: 'player_token_123',
})

// Listener payloads are typed by the event name.
const stopListening = tournamentRoomSession.on('change', changePayload => {
  console.log(changePayload)
})

stopListening()

change: object

Defined in: packages/ts-sdk/src/resources/tournament-room-types.ts:72

connectionState ​

connectionState: ConnectionState

errors ​

errors: readonly ErrorPayload[]

snapshot ​

snapshot: TournamentRoomSnapshot | undefined


chatMessage ​

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 room player.
const tournamentRoomSession = simulatorClient.tournamentRooms.createSession({
  roomId: 'room_123',
  playerToken: 'player_token_123',
})

// Listener payloads are typed by the event name.
const stopListening = tournamentRoomSession.on('chatMessage', chatMessagePayload => {
  console.log(chatMessagePayload)
})

stopListening()

chatMessage: LobbyChatMessage

Defined in: packages/ts-sdk/src/resources/tournament-room-types.ts:63


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 room player.
const tournamentRoomSession = simulatorClient.tournamentRooms.createSession({
  roomId: 'room_123',
  playerToken: 'player_token_123',
})

// Listener payloads are typed by the event name.
const stopListening = tournamentRoomSession.on('connectionState', connectionStatePayload => {
  console.log(connectionStatePayload)
})

stopListening()

connectionState: ConnectionState

Defined in: packages/ts-sdk/src/resources/tournament-room-types.ts:71


error ​

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 room player.
const tournamentRoomSession = simulatorClient.tournamentRooms.createSession({
  roomId: 'room_123',
  playerToken: 'player_token_123',
})

// Listener payloads are typed by the event name.
const stopListening = tournamentRoomSession.on('error', errorPayload => {
  console.log(errorPayload)
})

stopListening()

error: ErrorPayload

Defined in: packages/ts-sdk/src/resources/tournament-room-types.ts:66


matchReady ​

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 room player.
const tournamentRoomSession = simulatorClient.tournamentRooms.createSession({
  roomId: 'room_123',
  playerToken: 'player_token_123',
})

// Listener payloads are typed by the event name.
const stopListening = tournamentRoomSession.on('matchReady', matchReadyPayload => {
  console.log(matchReadyPayload)
})

stopListening()

matchReady: TournamentRoomMatchReadyPayload

Defined in: packages/ts-sdk/src/resources/tournament-room-types.ts:65


message ​

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 room player.
const tournamentRoomSession = simulatorClient.tournamentRooms.createSession({
  roomId: 'room_123',
  playerToken: 'player_token_123',
})

// Listener payloads are typed by the event name.
const stopListening = tournamentRoomSession.on('message', messagePayload => {
  console.log(messagePayload)
})

stopListening()

message: TournamentRoomServerMessage

Defined in: packages/ts-sdk/src/resources/tournament-room-types.ts:70


playerPresence ​

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 room player.
const tournamentRoomSession = simulatorClient.tournamentRooms.createSession({
  roomId: 'room_123',
  playerToken: 'player_token_123',
})

// Listener payloads are typed by the event name.
const stopListening = tournamentRoomSession.on('playerPresence', playerPresencePayload => {
  console.log(playerPresencePayload)
})

stopListening()

playerPresence: RoomPlayerPresenceEvent

Defined in: packages/ts-sdk/src/resources/tournament-room-types.ts:64


pong ​

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 room player.
const tournamentRoomSession = simulatorClient.tournamentRooms.createSession({
  roomId: 'room_123',
  playerToken: 'player_token_123',
})

// Listener payloads are typed by the event name.
const stopListening = tournamentRoomSession.on('pong', pongPayload => {
  console.log(pongPayload)
})

stopListening()

pong: object

Defined in: packages/ts-sdk/src/resources/tournament-room-types.ts:69

nonce? ​

optional nonce?: string | null


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 room player.
const tournamentRoomSession = simulatorClient.tournamentRooms.createSession({
  roomId: 'room_123',
  playerToken: 'player_token_123',
})

// Listener payloads are typed by the event name.
const stopListening = tournamentRoomSession.on('snapshot', snapshotPayload => {
  console.log(snapshotPayload)
})

stopListening()

snapshot: TournamentRoomSnapshot

Defined in: packages/ts-sdk/src/resources/tournament-room-types.ts:62


welcome ​

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 room player.
const tournamentRoomSession = simulatorClient.tournamentRooms.createSession({
  roomId: 'room_123',
  playerToken: 'player_token_123',
})

// Listener payloads are typed by the event name.
const stopListening = tournamentRoomSession.on('welcome', welcomePayload => {
  console.log(welcomePayload)
})

stopListening()

welcome: TournamentRoomWelcomePayload

Defined in: packages/ts-sdk/src/resources/tournament-room-types.ts:61

Released under the MIT License.