Disclaimer: This is a living document and requirements may change in the future, we will aim to keep this document up to date with changes to our integration process.
Last updated:01/14/2022
At present, Leaderboards are populated and shown for Tournament-enabled games. To prevent player cheating, we must ensure that critical gameplay and score submission and computation is done on a remote server and not on player devices.
Before - everything is running on player device
After - Game Logic is done on a remote server and not on player device
To this end, Colyseus game server technology was selected as a mature, stable, documented, and open source platform.
Colyseus version 0.14 is used.
Games ideally should be able to run on 2 modes.
Tournament — game logic is done on Colyseus server
The OPArcade system sends the following parameters when launching in Tournament Mode. Parameters in RED are required to be passed to Colyseus upon client creation.
In production, the OPArcade system passes these parameters on launch by sending a GET request to your hosted game. (https:xyz.com/?playerId=&token=&tourneyId=******). Your game then passes it to Colyseus when calling joinOrCreate.
Sample parsing inside Unity Code — using Application.absoluteURL
join():Promise<void> {
return new Promise((resolve, reject) => {
this.client
.joinOrCreate<ITriskaState>('triska_room', {
playerId: this.playerId,
token: this.otp,
tourneyId: this.tourneyId,
sessionId: this.sessionId,
walletAddress: this.wallet_address //optional - useful if game will be using player NFT's
})
.then((room) => {
this.room = room;
this.processRoomMessages(this.room);
resolve();
})
.catch(reject);
});
}
For Fun — game logic is done on player device.
Games should send a postMessage upon end of gameplay.
The message should send “end-round”. It informs the i-frame container parent of game completion.
window.parent.postMessage("end-round", "*");
For Unity, please use https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html as reference. Create a script calling window.parent.postmessage and then call the script from within Unity.
Implement the onAuth function
// Authorize client based on provided options before WebSocket handshake is complete
async onAuth(client, options) {
this.playerId = options.playerid;
this.tourneyId = options.tourneyid;
this.token = options.otp;
this.walletAddress = options.walletAddress; //optional
if (this.playerId && this.tourneyId && this.token) {
// just return true here when developing
return await this.api.validateOtp(this.playerId, this.tourneyId, this.token);
}
return false;
}
Create a submitScore stub