Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.username = data.username;
this.p2body = false;
// set scene and position:
this.state = new PlayerState(player.state);
this.canAttack = true;
} catch (err) {
ErrorManager.error(['Missing user data.', err]);
}
}
}
type('string')(Player.prototype, 'sessionId');
type('string')(Player.prototype, 'username');
type('number')(Player.prototype, 'status');
schema.defineTypes(Player, {state: PlayerState});
module.exports.Player = Player;
import { Context, defineTypes, MapSchema, Schema, type } from '@colyseus/schema';
import { Client } from '..';
import { Room } from '../Room';
/**
* Create another context to avoid these types from being in the user's global `Context`
*/
const context = new Context();
class Player extends Schema { // tslint:disable-line
public connected: boolean;
public sessionId: string;
}
defineTypes(Player, {
connected: 'boolean',
sessionId: 'string',
}, context);
class State extends Schema { // tslint:disable-line
public players = new MapSchema();
}
defineTypes(State, {
players: { map: Player },
}, context);
/**
* client.joinOrCreate("relayroom", {
* maxClients: 10,
* allowReconnectionTime: 20
* });
*/
const context = new Context();
class Player extends Schema { // tslint:disable-line
public connected: boolean;
public sessionId: string;
}
defineTypes(Player, {
connected: 'boolean',
sessionId: 'string',
}, context);
class State extends Schema { // tslint:disable-line
public players = new MapSchema();
}
defineTypes(State, {
players: { map: Player },
}, context);
/**
* client.joinOrCreate("relayroom", {
* maxClients: 10,
* allowReconnectionTime: 20
* });
*/
export class RelayRoom extends Room { // tslint:disable-line
public allowReconnectionTime: number = 0;
public onCreate(options) {
this.setState(new State());