Getting the user in ON_TIMEOUT

103 views
Skip to first unread message

Don Morrison

unread,
Apr 12, 2022, 3:50:57 PM4/12/22
to nodeGame
Sorry, yet another question related to REMOTE_DISPATCH / auth.

So, we’re using URLs of the form

http://<somplace>/wroom/auth/<user>

to enter a waiting room that uses REMOTE_DISPATCH to pass along a user
identifier, <user>. Since <user> is passed along to the
REMOTE_DISPATCH prepocess() function I can pass it along to the target
of the redirection. But if the user times out in the waiting room we’d
like to make a record of who it was that timed out, so we can at least
pay them for their wasted waiting time. I’ve tried the following:

| ON_TIMEOUT: function() {
| // TODO how do I get the full URL that sent us here so I can
pull out the user id?
| node.say('NOGROUP', 'SERVER', window.location.href);
| },
|
| ON_INIT: function(wr) {
| this.node.on.data('NOGROUP', function(msg) {
| fs.appendFileSync("games/wroom/waiting_room.csv",
| `"${msg.data.replace(/"/g, '""')}",${new
Date()},no group formed\n`);
| });
| },

But it appears window.location.href has the “/auth/<user>” stripped
away; that is, it’s just:

http://<someplace>/wroom

Any idea how I can get the <user> in this context?

Thanks!


--
Don Morrison <d...@ringing.org>
“Behavioral science is not for sissies.”
— Steven Pinker, /The Blank Slate/

Stefano B

unread,
Apr 12, 2022, 4:49:38 PM4/12/22
to node...@googlegroups.com
There are two callbacks on timeout, for the server one for the client. Here how you can get the player id for both:

ON_TIMEOUT: function() {
    let id = node.player.id;
},

ON_TIMEOUT_SERVER: function(playerObj) {
    let id = playerObj.id;


You probably want to do everything within the server callback.

--
You received this message because you are subscribed to the Google Groups "nodeGame" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodegame+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodegame/CAO9hiFWmTFxgN0xZryh93gcyRoOrnYjmxo3%2BE0LpBHbinrUZHA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages