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

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
: [],
}
console
.
log
(
matchSessionState
)

Example

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

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

console.log(idleState.connectionState)

See

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

Properties

connectionState

Example:

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

const 
matchSessionState
: MatchSessionState = {
connectionState
: 'idle',
errors
: [],
events
: [],
errorMessages
: [],
} const {
connectionState
} =
matchSessionState
console
.
log
(
connectionState
)

connectionState: ConnectionState

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

Current transport state.


errorMessages

Example:

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

const 
matchSessionState
: MatchSessionState = {
connectionState
: 'idle',
errors
: [],
events
: [],
errorMessages
: [],
} const {
errorMessages
} =
matchSessionState
console
.
log
(
errorMessages
)

errorMessages: readonly string[]

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

Human-readable error summaries.


errors

Example:

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

const 
matchSessionState
: MatchSessionState = {
connectionState
: 'idle',
errors
: [],
events
: [],
errorMessages
: [],
} const {
errors
} =
matchSessionState
console
.
log
(
errors
)

errors: readonly ErrorPayload[]

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

Recent engine or SDK errors.


events

Example:

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

const 
matchSessionState
: MatchSessionState = {
connectionState
: 'idle',
errors
: [],
events
: [],
errorMessages
: [],
} const {
events
} =
matchSessionState
console
.
log
(
events
)

events: readonly GameEvent[]

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

Recent game events, trimmed to the configured history limit.


matchId?

Example:

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

const 
matchSessionState
: MatchSessionState = {
connectionState
: 'idle',
errors
: [],
events
: [],
errorMessages
: [],
} const {
matchId
} =
matchSessionState
console
.
log
(
matchId
)

optional matchId?: string

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

Public match id when one is known.


seat?

Example:

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

const 
matchSessionState
: MatchSessionState = {
connectionState
: 'idle',
errors
: [],
events
: [],
errorMessages
: [],
} const {
seat
:
controlledSeat
} =
matchSessionState
console
.
log
(
controlledSeat
)

optional seat?: Seat

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

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
: [],
} const {
snapshot
:
matchSnapshot
} =
matchSessionState
console
.
log
(
matchSnapshot
)

optional snapshot?: GameState

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

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
: [],
} const {
welcome
} =
matchSessionState
console
.
log
(
welcome
)

optional welcome?: WelcomePayload

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

Latest welcome payload when the socket handshake has completed.

Released under the MIT License.