Reporting lifecycle events
Once your game is running inside the operator's iframe, use @moosehq/game-client-sdk's GameBridge to report its lifecycle back to the operator's shell. This is unrelated to getting the session token — GameBridge doesn't need the session token at all, it only reports the game's lifecycle to the shell:
import { GameBridge } from '@moosehq/game-client-sdk'
const bridge = new GameBridge()
bridge.notifyGameLoaded(currentBalanceMinor)
// BET_START/BET_END are a two-phase reveal, not two network moments — a
// server-side spin/settle call typically resolves the whole round
// (including any win) in one response, so notify BET_START only once
// that result is known and you're about to start revealing it:
const result = await submitBet(betAmountMinor) // your own server-side integration (see ./server-integration)
if (result.declined) {
bridge.notifyBetEnd('declined', betAmountMinor, result.balanceMinor)
bridge.notifyBalanceExhausted()
} else {
bridge.notifyBetStart(betAmountMinor, result.balanceMinor - betAmountMinor) // after this wager's debit, before any win
await playReveal(result) // your own reveal animation, if any — purely cosmetic
bridge.notifyBetEnd(result.outcome, betAmountMinor, result.balanceMinor, result.winAmountMinor)
}
// player clicked an in-game "back to lobby" control:
bridge.notifyExitGame()GameBridge's constructor also accepts target (defaults to window.parent) if you need to override where messages are sent — mainly useful for tests; a game running normally inside an operator's iframe should rely on the default.
Reporting a game's lifecycle is unrelated to bot-detection signals — that's a separate SDK entry point (@moosehq/game-client-sdk/behavior-reporter), covered in its own guide.
Full reference
See @moosehq/game-client-sdk reference for every exported type and method signature, including the protocol module the shell side implements its listener against.