Connector
To integrate with the RGS, you must download the script containing the Connector and execute it. Here are two different ways to do it:
Download the Connector
const scriptElement = document.createElement('script');
scriptElement.src = new URLSearchParams(window.location.search).get("ecf")
?? "https://prod.rgsplatform.win/games/res/lib/ecf_rgs.js";
scriptElement.type = 'module';
let promise = new Promise<void>(res => scriptElement.addEventListener('load', () => res()));
document.head.appendChild(scriptElement);
await promise;
Get the Connector ready to use
Once the Connector is downloaded, you can obtain it:
const ETHEREAL = window.ethereal;
Make sure the Connector is ready to use by waiting for it to be ready:
await ETHEREAL.isReady();
Establish the contract
For the Connector to be able to decode the Proto messages sent from the RGS it will need a game contract. Follow this steps to stablish the contract:
Create the PROTO file
Create a proto file with the contract between the game client and the game engine. It should look like this:
/** Contract between the client and the server for the game comunication. */
syntax = "proto3";
/** Structure of the data received as response on init calls */
message InitResponse {
repeated int64 bets = 1; // This is an example
...
}
/** Structure of the data sent to the engine as request on play calls */
message PlayRequest {
int32 betIndex = 1; // This is an example
...
}
/** Structure of the data received as response from the engine on play calls */
message PlayResponse {
bool caught = 1; // This is an example
...
}
You need to keep the name of the 3 messages (InitResponse, PlayRequest and PlayResponse).
Export the PROTO file to JSON
To generate the Json file from the Proto you can use the pbjs library.
Install it as a normal npm package:
npm install pbjs --save-dev
And execute it to generate the json file from the proto:
pbjs -t json --no-beautify ./game.proto > ./game.json
Stablish the contract in the Connector
Notify the Connector of the contract with the json generated previously:
import contract from "../contract/game.json";
ETHEREAL.rgs.setGameContract(contract);
Game flow
Once the contract has been stablished, you can start making calls to the connector.
You have the full flow here.
Comunicating with the Connector
Listeners
To receive notifications about different events triggered by the casino or platform, you must specify to the Connector the callbacks needed for each action:
/** Action to take when there is a request to pause the game. */
ETHEREAL.onRequestPauseGame(() => { /** Your code **/ });
/** Action to take when there is a request to resume the game. */
ETHEREAL.onRequestResumeGame(() => { /** Your code **/ });
/** Action to take when an external source requests to update the balance. */
ETHEREAL.onRequestUpdateBalance((balance: number) => { /** Your code **/ });
:::doc More information Check the full list of listeners here :::
Notify the Connector
When the game performs certain actions, they should be notified to the Connector:
/** Notify that the game is ready to start playing. */
ETHEREAL.notifyGameReady();
:::doc More information Check the full list of notifications here :::
Connector functionality
Some actions related with the casino should be performed though the Connector:
/** Request to reload the game. */
ETHEREAL.reloadGame();
:::doc More information Check the full list of functionality here :::
Connector data
The connector collect data from the game and the server that's available for the game client to see.
Use this data to hide or show functionality / ui depending on what the regulation or casino the game is currenctly in allows.
/** Indicates whether the game supports autoplay. */
ETHEREAL.data.allowAutoplay();
/** Return if the current round is finished. If true, next play will start a new round. */
ETHEREAL.rgs.data.isRoundEnd(): boolean;
:::doc More information Check the full list of data available here :::
Universal UI
The connector provides a general UI with common functionality, such as showing messages. This is optional, but make the development easier.
:::doc More information Check all the functionalities of the UI here :::
Plugins
The connector offer extra functionality in the form of plugins:
Promotions
To allow the casino to create and use promotional rounds in your game.
:::doc More information Full explanation on how to use it here :::
Player history
To allow the player and the operator to check previously played rounds.
:::doc More information Full explanation on how to use it here :::
Jackpot
To allow the casino to add jackpots in the game.
:::doc More information Full explanation on how to use it here :::