Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: ClockTimer is not a constructor #8

Closed
Liima opened this issue Jul 17, 2017 · 2 comments
Closed

TypeError: ClockTimer is not a constructor #8

Liima opened this issue Jul 17, 2017 · 2 comments

Comments

@Liima
Copy link

Liima commented Jul 17, 2017

I'm trying to get the tic-tac-toe sample colyseus game up and running on my machine, and I'm getting this error when I attempt to connect to the game. Here is the top of the TicTacToe.js file which is throwing the error:

var Room = require('colyseus').Room
  , ClockTimer = require('clock-timer.js')

const PATCH_RATE = 20
    , TURN_TIMEOUT = 10

class TicTacToe extends Room {

  constructor (options) {
    // call 'update' method each 50ms
    super(options, 1000 / PATCH_RATE)

    this.setState({
      currentTurn: null,
      players: {},
      board: [[0, 0, 0], [0, 0, 0], [0, 0, 0]],
      winner: null,
      draw: null
    })

    this.clock = new ClockTimer(true)
  }

and here is the stack trace:

TypeError: ClockTimer is not a constructor
    at new TicTacToe (/home/daniel/javascript/test/server/rooms/tictactoe.js:21:18)
    at MatchMaker.create (/home/daniel/javascript/test/server/node_modules/colyseus/lib/match_maker.js:85:12)
    at MatchMaker.joinOrCreateByName (/home/daniel/javascript/test/server/node_modules/colyseus/lib/match_maker.js:48:75)
    at Server.onJoinRoomRequest (/home/daniel/javascript/test/server/node_modules/colyseus/lib/server.js:102:30)
    at Server.onMessage (/home/daniel/javascript/test/server/node_modules/colyseus/lib/server.js:77:14)
    at emitTwo (events.js:125:13)
    at WebSocket.emit (events.js:213:7)
    at Receiver.onbinary (/home/daniel/javascript/test/server/node_modules/colyseus/node_modules/ws/lib/WebSocket.js:848:10)
    at /home/daniel/javascript/test/server/node_modules/colyseus/node_modules/ws/lib/Receiver.js:628:18
    at /home/daniel/javascript/test/server/node_modules/colyseus/node_modules/ws/lib/Receiver.js:368:7

Help is greatly appreciated

@endel
Copy link
Member

endel commented Jul 17, 2017

Hi @Liima, sorry, some demos are quite outdated.

Please try using:

var ClockTimer = require('clock-timer.js').default;

Cheers!

@Liima
Copy link
Author

Liima commented Jul 17, 2017

Appreciate the quick reply, thanks!

@Liima Liima closed this as completed Jul 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants