The PostMessage API is a way to send messages between the the parent casino window and the experience frontend that is iframed within it.
(The casino doesn't send any messages to the experience, yet.)
playerBalances
{ type: "playerBalances", balances: { [currency: string]: number } }
Example:
{ type: "playerBalances", balances: { "BTC": 10000, "HOUSE": 20, "TBTC": 0 } }
Send this message to the casino upon initialization AND any time the player's balances change.
The casino expects you to send all of the player's balances every time even if only one balance has changed.
You must use this message to keep the player's balances in sync as much as possible since it's used to populate the "Take" form on the casino page. This form lets players request a withdrawal from your experience, so it's very alarming to the player if this form shows stale balances.
path
(Optional)
{ type: "path", path: string }
This message lets you update the casino URL so that you can support deep linking into your experience.
Send this message to the casino whenever your experience's internal URL changes.
The casino will then update its URL with #path=<path>
. e.g. https://moneypot.com/play/dice#path=/bets/123
When the user navigates to that URL, #path=/bets/123
is then appended to your experience iframe URL. e.g. https://dice.example.com/bets/123
.