Basic multiplayer with OAuth
Initialization
To start using your plugin you need first initialize it:
Then you need to attach UI components into your activity (the button and the webview):
Registering in-game player id and metadata:
So that we can tell you for which players you have to start the game:
Forcefully open escs view
You can use this to open escs main view programmatically, not requiring the user to tap the button
Starting the game
When players click on the "Press Ready" button, escs sends you the event to start the game. escs can send it to your game client and to your backend. To receive the event in the game client register OnGameSetStart event callback
where data is GameSetStartData object:
setId - setId of started set (string)
tournamentId - tournamentId of the set (string)
matchId - matchId of the set (string)
roundId - roundId of the set (this is in fact id of the set "results") (string)
globalMetadata - metadata string that can be set in the game dashboard (string)
setEndTimeUnix - game's set max end time in unix time
pariticipants - list of lists of Participant. Each sub-list is considered a "team". So if the game is 2vs2, then you will get list of 2 lists, each having 2 objects inside. Those 2 lists are 2 lists with 2 players each. In case of 1vs1 game, you will receive a list of 2 lists, each having 1 object inside - thus the team contains only one player. Participant object consists of:
playerId - escs player id (string)
ingamePlayerId - registered in-game player id via registerInGamePlayerId (string)
username - user's escs username (string)
firstName - user's escs first name (string)
lastName - user's escs last name (string)
avatar - user's escs avatar image url (string)
ingameMetadata - in-game metadata that was registered via registerInGamePlayerId (string)
To receive the event on your backend enter the corresponding endpoint in the client.demo.escs.io dashboard in the edit game information section.
escs sends the event in the following format:
If you are using your backend to receive this event, then OnGameSetStart callback in the game client will be triggered only after your backend responded with 200.
When the tournament ends escs send a corresponding event to the same endpoint in the following format:
If you want to get player's tournament rewards, you should get them after you receive the tournament end event as described here
Ending the game
After the game ends send the results via POST to escs API endpoint https://api.demo.escs.io/rpc/SetRoundResult
Clean Up
Don't forget to clean up on destroying your activity:
Performing actions before allowing users to join a tournament
If you wish to perform certain actions when a user wants to join any tournament (i.e. show ads, etc.), you can use the following callback – the plugin will call it when the user presses the "I'm in" button on the main escs tournament page. To let the user join the tournament, you should call resolve(true) method, or resolve(false) to deny this possibility.
NOTE: in order for this callback to be activated, you should set up this option in the client dashboard as shown below
When creating a tournament series for your game select the "Show Ads on "I'm in" checkbox as shown below to activate additional actions before the user can join a tournament.
Video chat/streaming integration
In order for your app to support escs' video chat and streaming capabilities you need to call back the plugin in some key lifecycle areas of your app. This is required so that plugin can receive audio and camera permission's result and also request screen recoding for streaming. If your app also overrides these methods, just add call the escs methods before your own processing.
NOTE: You will also need to add microphone, audio and camera permissions to your AndroidManifest.xml, for example:
Supporting streaming with API level 29+
With API 29 and higher Android became more strict with permissions and background services. If your app targets compileSdkVersion 29 and/or targetSdkVersion 29 or higher you need to add the following to your AndroidManifest.xml inside Application node:
This directive will register a foreground service for streaming integration. Note that otherwise the app will crash when user gives permission for screen recoding. If your app targets API less than 29, then you don't need anything.
OAuth integration for fast user registration
Create the oAuth app as described here: Using escs OAuth for sign in
Implement the callback to send the access token to escs as described below.
Supporting user login using the game account (oAuth-like)
You can use our option for user game profile integration and allow your users to log in to our system without requiring them to manually create an escs account. Then the user will see an additional button "log in using %game_name% account" on the main escs screen. In order to support this, first, you need to follow the required steps in the client dashboard and set up the necessary fields as described in the corresponding docs section: Using escs OAuth for sign in. Note that you will also need to create an additional endpoint in your game's backend for the account system for verifying tokens. After this you will only need to implement one callback in your game:
where
list
- list of requested profile permissions (string), for example ["email", "id"]respond
- a function that is used to respond to this profile permissions request; you may want to ask the user to accept the requested permissions list in a dialog, or allow them to select only some of them; such dialog, if any, you should create and present to the user by yourself; when the user responded to it, you can use respond function to send user's choices to escs:token
- user access token, which will be used by escs backend to obtain profile information from your game's backend (string)acceptedPermissionList
- here you supply permissions that the user accepted, if any (list of strings)
How to get a list of tournament participants
Just call the following endpoint POST /v2/tournament-participant/get with the following parameters:
Example of the response:
How to get the players and their tournament rewards
Just call the following endpoint POST /v2/ingame-rewards/get with the following parameters:
Example of the response:
How to get player's rewards from the tournaments
Just call the following endpoint POST /v2/ingame-rewards/get with the following parameters:
Example of the response:
Last updated