JS WatchThis
WatchThis is a subset of escs services to provide easy drop-in social features for your app, like videochat, event sync between participants and so on.
Connecting plugin to your project.
To obtain the plugin please connect with us.
Then you can import it in your js project's package.json dependency section:
If you are using react, then just import these:
You can use ESCSButton and ESCSWebView as your regular react components in JSX like this:
Otherwise, if you are using plain vanilla js or any other js framework, you need to use vanilla js imports:
Then in your main js file you need to initialize react render:
Where 'app' is the id of the root DOM element.
and in your callback you can instantiate two ESCS WatchThis components:
where divEscsButton and divEscsWebView are your DOM elements, where Escs Button and Escs WebView will be rendered
Also, for your convenience, you can inject service in the global window scope, to be able to access it in all parts of your game:
After this all you need is to initialize the plugin to get WatchThis overlay in your app.
Initialization
To start using your plugin you need first initialize it:
where:
public_key
- a key that you've obtained from usbase_url
- url for the core ESCS service. You can obtain it from usplayer_base_url
- url for the player's ESCS service. You can obtain it from usanalyticsEnv
- environment to use for analytics reporting
Sending shared events for party participants
It's very easy to send shared stream of events between party participants. All the events send from any of the participant's app instance will be broadcasted to everyone in the party:
where eventName is string and eventParams is an object containing params for that event.
To subscribe to an event stream coming from each participant you can use this method:
where again eventName is the name of the event you want to listen for and params are params send along with it. Thus using these two methods you can easily sync any state between all the participants in your party.
Last updated