Skip to content

bot.js launch unsuccessful when in levels folder or when requiring clientId #143

@StolkArjen

Description

@StolkArjen

As discussed on https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/nodegame/i50yUK3pju0/rbobBo2eAQAJ, I'm experiencing a two-fold bug when trying to launch bot.js (clicking the "Play With Bot" button in the waiting room).

Background:
This nodeGame consists of two levels, including an instruction level (residing in game/) and a game level (in levels/):
Screen Shot 2020-08-10 at 10 10 24 PM

Problem situation 1:
When clicking the "Play With Bot" button in the waiting room (of levels/), it complains that bot.js is not found, see the error message below. Not sure if it's related, but I've found previously that the game.settings.js from game/ are not overwritten by any game.settings.js in levels/. This is fine for my game actually, so I'm only mentioning it in the case it's helpful for understanding why it doesn't seem to find bot.js in the levels/ folder (note, the respective player.js and logic.js functions work well).

Possible solution: note that the error refers to channel "tcg", whereas bot.js resides not in the client_type folder of tcg but of its game subdirectory (tcg/game/client_type). So, a solution would possibly involve moving bot.js up a level (ugly) or nodegame looking for subfolders in the case of a levels/ situation.

Client connected to waiting room: 402878243.77684724
NPL 1
error: ServerNode caught an exception:
Error: ServerChannel.connectBot: client type not found: bot (channel: tcg)
at ServerChannel.connectBot (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-server/lib/ServerChannel.js:1411:15)
at WaitingRoom.dispatchWithBots (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-server/lib/rooms/WaitingRoom.js:483:22)
at Game. (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-server/lib/rooms/WaitingRoom.js:816:14)
at Game. (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-client/listeners/aliases.js:45:43)
at Game. (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-client/lib/modules/alias.js:80:26)
at EventEmitter.emit (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-client/lib/core/EventEmitter.js:216:31)
at NodeGameClient.EventEmitterManager.emit (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-client/lib/core/EventEmitter.js:722:31)
at Socket.onMessageFull (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-client/lib/core/Socket.js:564:23)
at SocketDirect.message (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-client/lib/sockets/SocketDirect.js:100:26)
at SocketDirect.send (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-server/lib/sockets/SocketDirect.js:212:24)

Problem situation 2:
As situation 1, but with the addition of a copy of bot.js in the game/ folder (besides in the levels/ folder). If I understand correctly, bot.js shouldn't even be at this location since it only applies to the game level, but I tried it anyway to see if it mattered. Surprisingly, bot.js seems to be found by the game at this location, but now it complains about the clientId. The clientId is something we recently added, ie launching using "localhost:8080/auth/1/" as the default. I guess the failure is due to bot.js not launching with a clientId, but I don't know how to overwrite this behavior. Perhaps it's not an even issue if we can fix problem situation 1, though it might apply there too. Here's the error message anyway:

Client connected to waiting room: 128975498.32708366
NPL 1
error: ServerNode caught an exception:
TypeError: Cannot read property 'clientId' of undefined
at PlayerServer.idGen [as generateClientId] (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/games/tcg/auth/auth.js:70:24)
at PlayerServer.GameServer.onConnect (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-server/lib/GameServer.js:624:20)
at SocketDirect.connect (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-server/lib/sockets/SocketDirect.js:87:27)
at SocketDirect.connect (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-client/lib/sockets/SocketDirect.js:73:27)
at Socket.connect (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-client/lib/core/Socket.js:346:21)
at NodeGameClient.NGC.connect (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-client/lib/modules/connect.js:81:21)
at ServerChannel.connectBot (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-server/lib/ServerChannel.js:1569:9)
at WaitingRoom.dispatchWithBots (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-server/lib/rooms/WaitingRoom.js:483:22)
at Game. (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-server/lib/rooms/WaitingRoom.js:816:14)
at Game. (/Users/arjsto/Projects/Web/software/nodegame-v5.9.0/node_modules/nodegame-client/listeners/aliases.js:45:43)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions