add auth
This commit is contained in:
parent
edd005cb4d
commit
5414c719f1
6 changed files with 141 additions and 10 deletions
|
@ -155,7 +155,11 @@ class Game extends GameBasic {
|
|||
player.ref = false;
|
||||
}
|
||||
|
||||
this.ws.send(JSON.stringify(player.legalProps.map(prop => player[prop])));
|
||||
let p = player.legalProps.map(prop => player[prop]);
|
||||
|
||||
p.splice(0,0,'SYNC');
|
||||
|
||||
this.ws.send(JSON.stringify(p));
|
||||
}
|
||||
recv({ data }) {
|
||||
let { player } = this;
|
||||
|
@ -225,6 +229,7 @@ class Game extends GameBasic {
|
|||
if (this.entities.length == 0) this.entities = [this.player];
|
||||
}
|
||||
async init() {
|
||||
let tok = new URL(window.location).searchParams.get('token');
|
||||
super.init();
|
||||
|
||||
let that = this;
|
||||
|
@ -235,6 +240,9 @@ class Game extends GameBasic {
|
|||
|
||||
this.ws.addEventListener('open', function () {
|
||||
that.sync(true);
|
||||
if (tok) {
|
||||
that.ws.send(JSON.stringify(["AUTH",tok]));
|
||||
}
|
||||
setInterval(function () { that.sync() }, 1000 / 5);
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue