How to use the colyseus.Room function in colyseus

To help you get started, we’ve selected a few colyseus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github damian-pastorini / reldens / server / rooms / game-room.js View on Github external
var Room = require('colyseus').Room;
var State = require('../modules/state').state;
var DataLink = require('../modules/datalink');
var share = require('../../shared/constants');

class GameRoom extends Room
{

    onInit(options)
    {
        this.setState(new State());
    }

    onAuth(options)
    {
        if(options.isNewUser){
            // the last 3 values are for the default role_id = 1, status = 1 and state = 1:
github colyseus / colyseus.js / examples / rooms / chat_room.js View on Github external
var Room = require('colyseus').Room

class ChatRoom extends Room {

  constructor (options) {
    super(options)

    // this.useTimeline()

    this.setPatchRate(1000 / 192);

    this.setState({ messages: [] })

    // Call game simulation at 60fps (16.6ms)
    this.setSimulationInterval( this.tick.bind(this), 1000 / 60 )

    console.log("ChatRoom created!", options)
github colyseus / colyseus / colyseus-client / examples / rooms / chat_room.js View on Github external
var Room = require('colyseus').Room

class ChatRoom extends Room {

  constructor (options) {
    options.updateInterval = 1000
    super(options, { messages: [] })
    console.log("ChatRoom created!", options)
  }

  onJoin (client) {
    this.sendState(client)
    console.log("ChatRoom:", client.id, "connected")
  }

  onLeave (client) {
    // console.log("ChatRoom:", client.id, "disconnected")
github HenryDavidZhu / MazeBattles.com / rooms / mazebattles.js View on Github external
this.column = column;
    this.row = row;

    this.xPos = column * cellSize;
    this.yPos = row * cellSize;


    this.walls = [true, true, true, true]; // 0 = top, 1 = right, 2 = bottom, 3 = left
    this.visited = false; // Whether the cell has been traversed or not
}




const Room = require("colyseus").Room;

export class MazeRoom extends Room {
    // this room supports only 4 clients connected

    onInit (options) {
      this.maxClients = 2;
      this.maze = new Maze(23, 35);
      this.maze.createMaze();

      console.log("BasicRoom created!", options);

      this.broadcast(this.maze);
    }

    onJoin (client) {
        this.broadcast(`${ client.sessionId } joined.`);
github damian-pastorini / reldens / packages / rooms / login.js View on Github external
/**
 *
 * Reldens - RoomLogin
 *
 * This room is the base to authenticate every single client join.
 * Since we are hitting the storage to validate the client we doing it on each join.
 *
 */

 // @TODO: - Seiyria - can also do `const { Room } = require('colyseus');
const Room = require('colyseus').Room;

class RoomLogin extends Room
{

    onCreate(options)
    {
        this.config = options.config;
        this.loginManager = options.loginManager;
        this.validateRoomData = false;
    }

    async onAuth(client, options, request)
    {
        if(!options){
            return false;
        }
github colyseus / colyseus.js / examples / rooms / battle_room.js View on Github external
var Room = require('colyseus').Room

class BattleRoom extends Room {

  constructor (options) {
    super(options)
    this.setState({})
    console.log("BattleRoom created!", options)
  }

  requestJoin(options) {
    return (options.invalid_param != 10)
  }

  onJoin (client) {
    if (this.clients.length == 4) {
      this.lock()
github colyseus / colyseus / colyseus-client / examples / rooms / battle_room.js View on Github external
var Room = require('colyseus').Room

class BattleRoom extends Room {

  constructor (options) {
    options.updateInterval = 1100
    super(options)
    console.log("BattleRoom created!", options)
  }

  requestJoin(options) {
    return (options.invalid_param != 10)
  }

  onJoin (client) {
    if (this.clients.length == 4) {
      this.lock()