Skip to content
Last updated

Client Side Messaging

You can subscribe to in-game RubyPlay messages using postMessage API functionality.

Game to Wrapper Messages

Messages from the game are sent to the parent page. Each message has a standard structure and contains the following fields:

type: string;
sender: string;
lang: string;
data?: any;
  1. type is a string with a specific structure rp.g2w.RedirectToLobby where:
    • rp is an abbreviation of RubyPlay
    • g2w is a direction for notification - from game to wrapper
    • RedirectToLobby is a message name
  2. sender is a string with an ID code of the game from which the notification is being sent
  3. lang is a string with a language code
  4. data field is not mandatory and contains any additional data
Click here to see message examples...

Here are some examples:

{"type":"rp.g2w.payTableStatusUpdate","sender":"rp_34","lang":"en","data":{"isOpen":false}}
{"type":"rp.g2w.payTableStatusUpdate","sender":"rp_34","lang":"en","data":{"isOpen":true}}
{"type":"rp.g2w.gameRulesStatusUpdate","sender":"rp_25","lang":"da","data":{"isOpen":false}}
{"type":"rp.g2w.gameRulesStatusUpdate","sender":"rp_25","lang":"da","data":{"isOpen":true}}
{"type":"rp.g2w.paidRoundEnded","sender":"rp_76","lang":"en","data":{"win":0,"totalWin":0,"isBigWin":false}}
{"type":"rp.g2w.balanceUpdate","sender":"rp_34","lang":"en","data":{"balance":999620}}
{"type":"rp.g2w.paidRoundStarted","sender":"rp_54","lang":"es"}

The full list of messages that the game can send:

Message NameDescriptionAdditional Data
rp.g2w.RedirectToLobbyTriggers when a player redirects from the game to the casino lobby.
rp.g2w.soundStatusUpdateTriggers every time a player switches sounds in the game.enabled: boolean
rp.g2w.loadingEndedTriggers when the game loading finishes and the Start button appears.
rp.g2w.gameStartedTriggers when a player clicks the Start button and the reels become visible.
rp.g2w.gameRulesStatusUpdateTriggers when a player opens/closes the game rules.isOpen: boolean
rp.g2w.payTableStatusUpdateTriggers when a player opens/closes the paytable.isOpen: boolean
rp.g2w.gameHistoryStatusUpdateTriggers when a player opens/closes the game history.isOpen: boolean
rp.g2w.turboStatusUpdateTriggers when a player switches turbo mode (on/off).enabled: boolean
rp.g2w.fullscreenStatusUpdateTriggers when a player switches fullscreen mode (on/off).enabled: boolean
rp.g2w.featureTriggers when any game feature starts/ends (free spins, pick bonus, select bonus, etc.).inProgress: boolean
rp.g2w.autoplayTriggers when a player switches autoplay mode (on/off).inProgress: boolean
rp.g2w.balanceUpdateTriggers every time the balance in the game UI is updated (placed bet, win/lose money, etc.).balance: number
rp.g2w.systemPopupTriggers every time the system popup is shown/closed (errors, session timers, inactivity timers, etc.).shown: boolean
rp.g2w.paidRoundStartedTriggers when any paid round starts.
rp.g2w.paidRoundEnded Triggers when any paid round ends (any feature won in that round is also part of it). It also contains additional data:
  • win: equal to totalWin if only one action, otherwise it's the win from the last action.
  • totalWin: total win from all actions in the round.
  • isBigWin: true if it was a base spin with a win over 20 bets.

win: number;
totalWin: number;
isBigWin: boolean;
        
rp.g2w.betUpdate Triggers when a player changes the bet. It contains the following additional data:
  • betIndex: index of the new bet from available list
  • bet: value of the new bet (in cents)
  • totalBet: new bet multiplied by wager (in cents)

betIndex: number;
bet: number;
totalBet: number;
        

Wrapper to Game Messages

For this functionality, the casino must use the postMessage API and adhere to the following fields:

type: string;
data?: any;
  1. type is a string with a specific structure rp.w2g.refreshBalance where:
    • rp is an abbreviation of RubyPlay
    • w2g is a direction for notification - from wrapper to game
    • refreshBalance is a message name
  2. data field is not mandatory and contains any additional data

IMPORTANT: The entire message must be a JSON object. For example:

{"type":"rp.w2g.refreshBalance"}

The list of messages that the wrapper can send to the game:

Message NameDescription
rp.w2g.refreshBalanceThe casino can send this message to trigger an immediate balance update in the game. When the game receives this message, it will request an update from its server and refresh the UI with the new balance provided in the server's response.
rp.w2g.pauseThe casino can send this message to request a game pause. Pausing the game is not an immediate action—it depends on the current state of the slot machine (e.g., it must not be spinning). Once the game receives this message, it sends back a 'rp.g2w.gamePause': {"pause": true} post message.
rp.w2g.resumeThe casino can send this message to request a game resume. Once the game receives this message, it sends back a 'rp.g2w.gamePause': {"pause": false} post message.
rp.w2g.muteThe casino can send this message to mute the game. Once the game receives this message, it sends back a 'rp.g2w.soundStatusUpdate': {"enabled": false} post message.
rp.w2g.unmuteThe casino can send this message to unmute the game. Once the game receives this message, it sends back a 'rp.g2w.soundStatusUpdate': {"enabled": true} post message.
rp.w2g.stopAutoPlayThe casino can send this message to stop the autospin mode. Once the game receives this message, it sends back a 'rp.g2w.autoplay': {"inProgress": false} post message.
rp.w2g.toggleInfoPageThe casino can send this message to open the Info Page pop-up. On mobile, this will open the Settings pop-up and navigate to the Info Page tab. Once the game receives this message, it sends back a 'rp.g2w.payTableStatusUpdate': {"isOpen": boolean} post message.
rp.w2g.toggleGameRulesThe casino can send this message to open the Game Rules pop-up. On mobile, this will open the Settings pop-up and navigate to the Game Rules tab. Once the game receives this message, it sends back a 'rp.g2w.gameRulesStatusUpdate': {"isOpen": boolean} post message.
rp.w2g.toggleGameHistoryThe casino can send this message to open the Game History pop-up. On mobile, this will open the Settings pop-up and navigate to the Game History tab. Once the game receives this message, it sends back a 'rp.g2w.gameHistoryStatusUpdate': {"isOpen": boolean} post message.