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

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

Closed
StolkArjen opened this issue Aug 10, 2020 · 6 comments
Closed

Comments

@StolkArjen
Copy link

StolkArjen commented Aug 10, 2020

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💯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)

@shakty
Copy link
Member

shakty commented Aug 12, 2020

This should be now fixed in the master branch. The situation 2 is a in fact a non-issue, because bots have no info.query parameter, so you should adapt auth.js file to take this possibility into account. E.g.,

if (info.query && info.query.clientId) ...

I keep this open as I am investigating the issue with overwriting the settings file.

@StolkArjen
Copy link
Author

StolkArjen commented Aug 12, 2020

Just for implementing and trying these fixes (thanks!) on my side, are the ones you made to lib/ServerChannel.js the most substantial ones?

More generally, what would be the most optimal way to keep incorporating the latest changes? I have a version of nodeGame that I have expanded on, as you know, to interact with a google script. This way, I wouldn't be able to simply pull in recent updates from the nodeGame github, without encountering conflicts? Also, I would have a git repo (game) inside another git repo (nodegame), and a possible mismatch between the nodeGame repo(s) on my computer and the one installed as a droplet on the digital ocean server?

@shakty
Copy link
Member

shakty commented Aug 12, 2020

Yes, you just need the ServerChannel changes. Unfortunately, since you have custom code running, merging can sometimes be painful. Just git pull, if your lucky it will work without problems, but if not you will need to resolve the conflict manually. Just ask in case of doubts.

@shakty
Copy link
Member

shakty commented Aug 13, 2020

I have now fixed in the master branch the merging of settings for levels, it should be working now, please try it.

@shakty
Copy link
Member

shakty commented Aug 13, 2020

Fixed and released 5.10.1

@shakty shakty closed this as completed Aug 13, 2020
@StolkArjen
Copy link
Author

StolkArjen commented Aug 16, 2020

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