colyseus / colyseus-examples

Examples for learning how Colyseus works
https://examples.colyseus.dev/
MIT License
178 stars 90 forks source link

Can't register a room other than "chat" #3

Closed gregmax17 closed 7 years ago

gregmax17 commented 7 years ago

In the index.ts file, I'm setting these lines from this:

// Register ChatRoom as "chat"
gameServer.register("chat", ChatRoom);

to this:

// Register ChatRoom as "chat"
gameServer.register("something", ChatRoom);

Will always result to this error:

./colyseus/node_modules/colyseus/lib/MatchMaker.js:153
        var room = null, handler = this.handlers[roomName][0], options = this.handlers[roomName][1];
                                                          ^

TypeError: Cannot read property '0' of undefined
    at MatchMaker.create (./colyseus/node_modules/colyseus/lib/MatchMaker.js:153:59)
    at MatchMaker.onJoinRoomRequest (./colyseus/node_modules/colyseus/lib/MatchMaker.js:62:45)
    at process.<anonymous> (./colyseus/node_modules/colyseus/lib/cluster/Worker.js:104:24)
    at emitTwo (events.js:111:20)
    at process.emit (events.js:191:7)
    at process.nextTick (internal/child_process.js:744:12)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
worker 88139 died. Respawn.

It appears the room must be named "chat". Is this the expected behavior, must the room always be called "chat"?

msqaddura commented 7 years ago

Hello, I am as well going through some difficulties with this library. but for your case did you try changing both the client and the server? in 01-basic.html you should add : var chatRoom = client.join("something");

endel commented 7 years ago

@msqaddura which difficulties are you going through?

@gregmax17 please upgrade to the latest versions of client and server. This error might've been an issue that has been fixed already. You can register as many rooms as you'd like and with any name.

Cheers!

msqaddura commented 7 years ago

@endel by my side all problems are solved, they were mainly due to migration and moving to es6. @gregmax17 to confirm @endel I have tried your case but did not get any error (so should be fixed now), only i would say is to add your room on the frontend as well

endel commented 7 years ago

I'm closing this for inactivity. Feel free to re-open this issue if you need to.