@valkyrie-fnd/valkyrie-event-adapter / ValkyrieWrapper
Create an instance of ValkyrieWrapper and pass it the parent/wrapper window as well as an implementation of ValkyrieReceiver
const vw = new ValkyrieWrapper(window.parent, window, receiverImpl);
// Call init to register all listeners
const removeListeners = vm.init();
//...
removeListeners();
Calling init()
the instance will set up listeners on window to listen for messages from wrapper.
Use ValkyrieWrapper methods to post messages to wrapper.
Create an implementation of ValkyrieReceiver
and pass it to ValkyrieWrapper
. Its methods will be called when wrapper posts messages.
- enterFullScreen
- exitFullScreen
- gameBusy
- gameIdle
- gameLoadError
- gameLoaded
- gameLoading
- init
- openCashier
- openHome
- openLobby
- pauseAutoPlay
- resumeAutoPlay
- stopAutoPlay
• new ValkyrieWrapper(parent
, currTarget
, receiver?
)
Used to post messages to parent window
Name | Type | Description |
---|---|---|
parent |
Window |
parent window to postMessage events to |
currTarget |
EventTarget |
target to listen on postMessage events. Most likely window |
receiver? |
ValkyrieReceiver |
implementation to receive messages from parent window |
• parent: Window
• receiver: ValkyrieReceiver
• target: EventTarget
▸ enterFullScreen(): void
If game provides fullscreen capability, call this when entering fullscreen so wrapper can handle that event.
void
▸ exitFullScreen(): void
If game provides fullscreen capability, call this when exiting fullscreen so wrapper can handle that event.
void
▸ gameBusy(): void
Call when game starts with player participation. Wrapper will avoid displaying any UI overlays while the game is busy.
void
▸ gameIdle(): void
Call when game becomes idle (betting time). Idle time can be used by the wrapper to display regulatory popups etc.
void
▸ gameLoadError(errorMsg
): void
Call when game fails to load. The wrapper can perform logging and automatic retries to try and recover.
Name | Type | Description |
---|---|---|
errorMsg |
string |
will end up on reason property of sent message |
void
▸ gameLoaded(): void
Call once the game is loaded and has the UI ready to be shown to the player. Should not be called while the game is still in process of loading assets etc
void
▸ gameLoading(progress
): void
Send game loading progress to wrapper. Should be called with 0 as soon as the page loads inside the iframe. Following, as the game starts loading, events with an increasing progress should be dispatched several times until the loading completes. A minimum number of 10 events is suggested.
Name | Type | Description |
---|---|---|
progress |
number |
number between 0-100 to signal loading progress. Will be clamped between 0-100 |
void
▸ init(): () => void
call init after creating an instance, to set up listeners.
const vm = new ValkyrieWrapper(window.parent, window, receiverImpl);
const removeListeners = vm.init();
//....
// to remove listeners call returned function from init
removeListeners();
fn
function to remove event listeners
▸ (): void
call init after creating an instance, to set up listeners.
const vm = new ValkyrieWrapper(window.parent, window, receiverImpl);
const removeListeners = vm.init();
//....
// to remove listeners call returned function from init
removeListeners();
void
function to remove event listeners
▸ openCashier(): void
Call when a Cashier or Deposit button is pressed within the game to instruct the wrapper to open the appropriate UI for that.
void
▸ openHome(): void
Call when Player navigates to home by pressing a "home" button.
void
▸ openLobby(): void
Call when a Lobby or Home button is pressed within the game. The wrapper will be closed and user will be navigated to lobby or licensee page depending on casino configuration
void
▸ pauseAutoPlay(): void
Send pause auto play event to wrapper. If autoplay has been started withing the game, in order to sync state of play with wrapper
void
▸ resumeAutoPlay(): void
Send resume auto play event to wrapper. If autoplay has been started withing the game, in order to sync state of play with wrapper
void
▸ stopAutoPlay(): void
Send stop auto play event to wrapper. If autoplay has been started withing the game, in order to sync state of play with wrapper
void