Skip to content

@my-swu/simulator-client


@my-swu/simulator-client / MatchSessionState

Interface: MatchSessionState ​

Defined in: packages/ts-sdk/src/match-session/session-state.ts:205

Public, token-free state snapshot for one match session.

This state can be stored in UI state managers because it intentionally omits the private seatToken.

Example:

ts
import type { MatchSessionState } from '@my-swu/simulator-client'

const matchSessionState: MatchSessionState = {
  connectionState: 'idle',
  errors: [],
  events: [],
  errorMessages: [],
  // Server-pushed match history, replayed into the session state.
  history: [],
}

console.log(matchSessionState)

Example ​

ts
import type { MatchSessionState } from '@my-swu/simulator-client'

const idleState: MatchSessionState = {
  connectionState: 'idle',
  errors: [],
  events: [],
  history: [],
  errorMessages: [],
}

console.log(idleState.connectionState)

See ​

https://simulator-sdk.my-swu.com/guide/match-session

Properties ​

aiStatus? ​

Example:

ts
import type { MatchSessionState } from '@my-swu/simulator-client'

const matchSessionState: MatchSessionState = {
  connectionState: 'idle',
  errors: [],
  events: [],
  errorMessages: [],
  // Server-pushed match history, replayed into the session state.
  history: [],
}

const { aiStatus } = matchSessionState

console.log(aiStatus)

optional aiStatus?: AiStatusPayload

Defined in: packages/ts-sdk/src/match-session/session-state.ts:207

Latest AI attachment/pause status announced by the server.


connectionState ​

Example:

ts
import type { MatchSessionState } from '@my-swu/simulator-client'

const matchSessionState: MatchSessionState = {
  connectionState: 'idle',
  errors: [],
  events: [],
  errorMessages: [],
  // Server-pushed match history, replayed into the session state.
  history: [],
}

const { connectionState } = matchSessionState

console.log(connectionState)

connectionState: ConnectionState

Defined in: packages/ts-sdk/src/match-session/session-state.ts:209

Current transport state.


errorMessages ​

Example:

ts
import type { MatchSessionState } from '@my-swu/simulator-client'

const matchSessionState: MatchSessionState = {
  connectionState: 'idle',
  errors: [],
  events: [],
  errorMessages: [],
  // Server-pushed match history, replayed into the session state.
  history: [],
}

const { errorMessages } = matchSessionState

console.log(errorMessages)

errorMessages: readonly string[]

Defined in: packages/ts-sdk/src/match-session/session-state.ts:217

Human-readable error summaries.


errors ​

Example:

ts
import type { MatchSessionState } from '@my-swu/simulator-client'

const matchSessionState: MatchSessionState = {
  connectionState: 'idle',
  errors: [],
  events: [],
  errorMessages: [],
  // Server-pushed match history, replayed into the session state.
  history: [],
}

const { errors } = matchSessionState

console.log(errors)

errors: readonly ErrorPayload[]

Defined in: packages/ts-sdk/src/match-session/session-state.ts:211

Recent engine or SDK errors.


events ​

Example:

ts
import type { MatchSessionState } from '@my-swu/simulator-client'

const matchSessionState: MatchSessionState = {
  connectionState: 'idle',
  errors: [],
  events: [],
  errorMessages: [],
  // Server-pushed match history, replayed into the session state.
  history: [],
}

const { events } = matchSessionState

console.log(events)

events: readonly GameEvent[]

Defined in: packages/ts-sdk/src/match-session/session-state.ts:213

Recent game events, trimmed to the configured history limit.


history ​

Example:

ts
import type { MatchSessionState } from '@my-swu/simulator-client'

const matchSessionState: MatchSessionState = {
  connectionState: 'idle',
  errors: [],
  events: [],
  errorMessages: [],
  // Server-pushed match history, replayed into the session state.
  history: [],
}

const { history } = matchSessionState

console.log(history)

history: readonly MatchHistoryFeedEntry[]

Defined in: packages/ts-sdk/src/match-session/session-state.ts:215

Recent match history entries supplied by the server.


matchId? ​

Example:

ts
import type { MatchSessionState } from '@my-swu/simulator-client'

const matchSessionState: MatchSessionState = {
  connectionState: 'idle',
  errors: [],
  events: [],
  errorMessages: [],
  // Server-pushed match history, replayed into the session state.
  history: [],
}

const { matchId } = matchSessionState

console.log(matchId)

optional matchId?: string

Defined in: packages/ts-sdk/src/match-session/session-state.ts:219

Public match id when one is known.


reconnectState? ​

Example:

ts
import type { MatchSessionState } from '@my-swu/simulator-client'

const matchSessionState: MatchSessionState = {
  connectionState: 'idle',
  errors: [],
  events: [],
  errorMessages: [],
  // Server-pushed match history, replayed into the session state.
  history: [],
}

const { reconnectState } = matchSessionState

console.log(reconnectState)

optional reconnectState?: MatchSessionReconnectState

Defined in: packages/ts-sdk/src/match-session/session-state.ts:221

Automatic reconnect progress, when recovering from an abnormal close.


seat? ​

Example:

ts
import type { MatchSessionState } from '@my-swu/simulator-client'

const matchSessionState: MatchSessionState = {
  connectionState: 'idle',
  errors: [],
  events: [],
  errorMessages: [],
  // Server-pushed match history, replayed into the session state.
  history: [],
}

const { seat: controlledSeat } = matchSessionState

console.log(controlledSeat)

optional seat?: Seat

Defined in: packages/ts-sdk/src/match-session/session-state.ts:225

Seat controlled by this session when known.


snapshot? ​

Example:

ts
import type { MatchSessionState } from '@my-swu/simulator-client'

const matchSessionState: MatchSessionState = {
  connectionState: 'idle',
  errors: [],
  events: [],
  errorMessages: [],
  // Server-pushed match history, replayed into the session state.
  history: [],
}

const { snapshot: matchSnapshot } = matchSessionState

console.log(matchSnapshot)

optional snapshot?: GameState

Defined in: packages/ts-sdk/src/match-session/session-state.ts:223

Latest authoritative private snapshot for this seat.


welcome? ​

Example:

ts
import type { MatchSessionState } from '@my-swu/simulator-client'

const matchSessionState: MatchSessionState = {
  connectionState: 'idle',
  errors: [],
  events: [],
  errorMessages: [],
  // Server-pushed match history, replayed into the session state.
  history: [],
}

const { welcome } = matchSessionState

console.log(welcome)

optional welcome?: WelcomePayload

Defined in: packages/ts-sdk/src/match-session/session-state.ts:227

Latest welcome payload when the socket handshake has completed.

Released under the MIT License.