Giter VIP home page Giter VIP logo

valkyrie-event-adapter's Introduction

valkyrie-event-adapter

Frontend library written in Typescript to use in game provider games to communicate with operator displaying your game.

Also used on operator side in order to map events from providers to your system.

Documentation

Usage

Installing

npm i @valkyrie-fnd/valkyrie-event-adapter

or using yarn

yarn add @valkyrie-fnd/valkyrie-event-adapter

Provider

If your're a provider and want to follow Valkyrie events you use ValkyrieWrapper.

In relevant places in your code you need to call ValkyrieWrapper to notify it of events that happen. Eg vm.gameLoaded() when the game's resources are finished loading.

When implemented fully, you can make use of the test site (read below) to verify your events are being sent as expected. Read the docs what functions exist and verify using the test site.

import { ValkyrieWrapper } from '@valkyrie-fnd/valkyrie-event-adapter';
//...
// Get valkyrieReceiver instance
const vw = new ValkyrieWrapper(window.parent, window, valkyrieReceiver);
const unregister = vw.init();

//....
// 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
vw.gameLoaded();

//...
// If you need to remove any event listeners
unregister();

valkyrieReceiver needs to implement the ValkyrieReceiver interface.

export interface ValkyrieReceiver {
  autoPlay?: (action: AutoPlayAction) => void
  volume?: (muted: boolean) => void
  refreshBalance?: () => void
}

Commands sent by the wrapper of your game should be handled by it.
Eg. when the wrapper send a autoplay command the autoPlay-function on ValkyrieReceiver will be called and your game should handle it.

unregister is a function that will remove event listeners that is added to the second parameter(window).

Read documentation full here

Operator

TBW

Test site

To verify a game send the correct events and has implemented ValkyrieReceiver interface correctly you can use the test site.

It is available here. To use it, simply paste a url to a game in the input field and validate all events are coming in as expected, as well as validating the game iframe responds to the events sent to it. test-site

The source code for the test site is available here.

Publishing

Make sure CHANGELOG is updated with relevant changes.

When ready to release then use Prepare release workflow to prepare a release. This will create a PR for you to merge. Upon merge of the PR a github release will be created as well as the package published to NPM.

valkyrie-event-adapter's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar gustavste avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.