Container Client Module

Matt Karl edited this page Dec 17, 2015 · 4 revisions

The Container Client module is a small plugin for Application which allows for communication between the Container and the Application across an <iframe> HTML element. The Application is run from within the <iframe> and the parent window (site or web app) can listen to events or call functionality on the content. This relies on Bellhop for managing the communication using JavaScript's postMessage API.

Features

  • Manage Single-play and continuous-play modes in Application
  • Allow Container to feature-detect Application (Sound, Captions, etc)
  • Allow Container to toggle captions, music, sound effects, voice-over or all sound
  • Allow Container to pause/resume Application

Dependencies

  • Bellhop The library which handles the communication between the Application and the parent iframe container.
  • Core Module

Installing

In order to use the Container Client module, make sure to include the module's JavaScript file within the springroll.json file within your project. The module needs to be included after the core.

"libraries": [
	"components/bellhop/dist/bellhop.min.js",
	"components/springroll/dist/core.min.js",
	"components/springroll/dist/modules/container-client.min.js"
],
"librariesDebug": [
	"components/bellhop/dist/bellhop.js",
	"components/springroll/dist/core.js",
	"components/springroll/dist/modules/container-client.js"
]

Application Plugin

Options

option.singlePlay (Boolean) If the game is played in single-play mode. When singlePlayEnd() is called it will tell the Container that the user is finished.

options.playOptions (Object) Optional play parameters that the Container can pass to the Application. For instance, say the Application content is math game about shapes, and you want the first level to be square and medium difficulty. These options are passed through Containers open and openRemote methods (see docs)

Properties

singlePlay (Boolean) Read-only version of the option.singlePlay

playOptions (Object) Read-only version of the option.playOptions

container (Bellhop) The instance of the Bellhop object that represents the parent window. Allows direct communication with the Container. See Bellhop docs for more information about using this object.

Methods

endGame([exitType='game_completed']) Self-exit method. In some contexts, this can be used to tell the Container to close the iframe.

singlePlayEnd() End a game that's in single-play mode.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.