GreenLogic integration
v1.0
Title
Message
Create new category
What is the title of your new category?
Edit page index title
What is the title of the page index?
Edit category
What is the new title of your category?
Edit link
What is the new title and URL of your link?
Game wrapper
Copy Markdown
Open in ChatGPT
Open in Claude
Game wrapper
How connect to server-wrapper
- Get EW from the server, URL you can get from your stakelogic manger
- Load it and apply to HTML dom, check example function
- After that you will have gcw object in global scope (window object)
- Connect your event handler
- Make subscription on events from server
Example how load wrapper
In order to start game on dev02 env with the custom script, use url: https://ngp.dev02-gs-stakelogic.com/play
playerId = player with this id must be created on stakelogic test platfrom before this
gameId is provided by StakeLogic
platform - desktop, mobile
HTML
x
<!DOCTYPE html><html lang="en"> <head> <link rel="icon" href="data:;base64,="> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <title>Game Template</title> <script type="text/javascript"> let url = "https://ngp.dev02-gs-stakelogic.com/play?playerId=svd1&gameId=1091009601&platform=desktop&gameJs=./build/gamename.js&thirdPartyEvent=true"; const userAndPassword = btoa("demo:demo"); function init() { let loginRequest = new XMLHttpRequest(); loginRequest.open("GET", url, true); loginRequest.onreadystatechange = () => { if (loginRequest.readyState === 4 && loginRequest.status === 200) { document.open(); document.write(serverResponse); document.close(); } } loginRequest.send(); } init(); </script></head><body></body></html>Example subscription controller
Typescript
// Example realization of event controllerexport type GcwEventListenerHashMap = { [ id: number ]: GcwEventListener}export type GcwEventListener = { type: gcw.api.GameEventType, callback: Function, singleCall: boolean;} export class GcwEventsController { private static gcwEventEmitters: Function[] = []; private static gcwEventListeners: GcwEventListenerHashMap = []; private static lastListenerKey: number = 0; private static ngsRequestId = 0; public static getGameClient(): void { var gameWrapperRoot: any = gcw; var gameWrapperGames = (gameWrapperRoot.games || (gameWrapperRoot.games = {})); return gameWrapperGames.gamename; } public static setEventEmitter(gcwEventEmitter: any) { this.gcwEventEmitters.push(gcwEventEmitter); } public static emitGcwEvent(type: gcw.api.GameEventType, data?: any) { if (type === gcw.api.GameEventType.NGS_REQUEST) { this.ngsRequestId++; data.id = this.ngsRequestId; } this.gcwEventEmitters.forEach((emitter: Function) => emitter(type, data)); } public static receiveGcwEvent(type: gcw.api.GameEventType, data?: any) { const listenersInterested = Object.keys(this.gcwEventListeners).filter((key: any) => { return this.gcwEventListeners[ key ].type === type; }) listenersInterested.forEach((key: any) => { this.gcwEventListeners[ key ].callback(data); if (this.gcwEventListeners[ key ].singleCall) { delete this.gcwEventListeners[ key ]; } }); } public static subscribeForGcwEvent(type: gcw.api.GameEventType, callBack: Function, singleCall: boolean = true): number { this.lastListenerKey++; this.gcwEventListeners[ this.lastListenerKey ] = { type: type, callback: callBack, singleCall: singleCall }; return this.lastListenerKey; } public static unSubscribeForGcwEvent(id: number) { delete this.gcwEventListeners[ id ]; }}Example usage
Javascript
GcwEventsController.subscribeForGcwEvent(gcw.api.GameEventType.INITIALIZE, (data: any) => { App.init(); // App.init(); function that start the game}); // Recive event from server GcwEventsController.subscribeForGcwEvent( 'UI_ON_INITIALIZE', // Event name this.initUI.bind(this), // Callback false); GcwEventsController.subscribeForGcwEvent( 'ON_BUTTON_CLICKED', // Event name this.onButtonClicked.bind(this), // Callback false); // Send evet to serverGcwEventsController.emitGcwEvent(gcw.api.GameEventType.NGS_REQUEST, { id: 0, date: new Date(), operation: { init: true, exit: false }, game: { "buttonCode": null, "confirm": null, "input": null, "hearthBeatForceGetBalance": null, "init": true, "forfeitFreeRounds": null, "forfeitBonus": null, "payInAmount": null }, configuration: { init: true }, jackpot: { init: true, timestamp: Date.now() }, social: { init: true } });###
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard
Last updated on
Next to read:
Enriched wrappernull
Discard Changes
Do you want to discard your current changes and overwrite with the template?
Archive Synced Block
Message
Create new Template
What is this template's title?
Delete Template
Message
