can someone teatch me how to use node.js in MPP?

410 views
Skip to first unread message

NaN-NaN-senpai(BR)

unread,
Jun 29, 2017, 1:01:04 AM6/29/17
to Multiplayer Piano Forum
how to use it in MPP?

Lamp

unread,
Jul 10, 2017, 1:05:49 AM7/10/17
to Multiplayer Piano Forum
I'd be interested in this as well.
I examined mpp's script (http://www.multiplayerpiano.com/script.js). The interesting part is under "internet science" (ctrl+F)
I downloaded http://www.multiplayerpiano.com/Client.js and tried the following commands:

Client = require('/home/me/Desktop/Client.js');
gClient
= new Client("ws://www.multiplayerpiano.com:443");
gClient
.setChannel("lobby");
gClient
.start();


Each of these were successful until the last one. Server responded with a 401 (Unauthorized).
So we need to authenticate somehow, maybe by sending a cookie or something?

After that I suppose you can just add the event listeners and do what you wish.

Lamp

unread,
Jul 18, 2017, 8:25:51 PM7/18/17
to mpp-...@googlegroups.com
So, multiplayer piano server requires authentication, but the OWOP server does not! Using the Client.js from http://ourworldofpixels.com/srcpiano/Client.js, I connected to it from my Nodejs Discord bot and IT WORKED!



See here; when I tried to connect to MPP from OWOP, it refuses:



But connecting to OWOP from MPP... WORKS!



and we can see the rooms:


So while we can't connect to official MPP server until we figure out how to authenticate to it, we can connect to OWOP server and have some fun!
Now to try to do something with it...

Lamp

unread,
Jul 18, 2017, 9:05:00 PM7/18/17
to mpp-...@googlegroups.com
and i've just made a DISCORD(.js) TO OWOP BRIDGE!!!! :D

Client = require('Client.js'); // get from http://ourworldofpixels.com/srcpiano/Client.js

gClient
= new Client("ws://ourworldofpixels.com:1234");
gClient
.setChannel('A room that is bridged to Discord');
gClient
.start();

var channel = undefined; // define this as whatever Discord channel you want to bridge to

gClient
.on('a', msg => {
 
if (msg.p._id !== gClient.getOwnParticipant()._id)
    channel
.send("**"+msg.p.name+":** "+msg.a);
});

client
.on('message', message => {
  if (message.author !== client.user && message.channel === channel)
    gClient
.sendArray([{m:"a", message: message.member.displayName+": "+message.content}]);
});

Lamp

unread,
Jul 19, 2017, 4:22:07 PM7/19/17
to mpp-...@googlegroups.com
OMG I DID IT!!!!!!!! I SOLVED IT!!!!!!! :DDDDDDDDDDDD

ok so
We need to send headers to the server on connecting or it'll refuse
The Client.js uses node ws which can take headers in as options.
The connection is made on line 74, so that's where we add our headers.

At first I tried just adding the cookies, but that didn't work
So i added all the headers that the MPP client normally sends, but then it said "invalid server key"
I removed the header "Sec-Websocket-Key"... AND IT WORKED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! AAAAAAAAAA


So one of those headers were needed to get in. It wasn't the cookies. I figured out that all it needs is the "Origin" header! And that's it!!



SO, here is a modified Client.js that'll send that necessary header to enable you to connect to the MPP server from Nodejs!


Then just use the following to connect:
Client = require('MPPclient.js');
gClient
= new Client("ws://www.multiplayerpiano.com:443");
gClient
.setChannel("MY EPIC NODEJS ROOM");
gClient
.start();


And that's it!! Now you can add event listeners and do awesome stuff. You can make chat bots exactly the same way you'd do it in MPP, just use `gClient.on` instead of `MPP.client.on`. And that Discord bridge... now you can use it with MPP (which is where all the fun is!)

const Client = require('MPPclient.js'); // get from https://gist.github.com/ledlamp/8c5872c73ee7ca57a1f396fc459f35c0

const gClient = new Client("ws://www.multiplayerpiano.com:443");
gClient
.setChannel("MY EPIC DISCORD-BRIDGED ROOM");
gClient.start();

var channel = undefined; // define this as whatever Discord channel you want to bridge to

// MPP to Discord

gClient
.on('a', msg => {
 
if (msg.p._id !== gClient.getOwnParticipant()._id)
    channel
.send("**"+msg.p.name+":** "+msg.a);
});

// Discord to MPP ('client' is the Discord client)

Habib Aina

unread,
Oct 22, 2020, 6:50:34 PM10/22/20
to Multiplayer Piano Forum
Can you send me the files on discord? The github page is missing.

Lamp

unread,
Oct 22, 2020, 6:56:39 PM10/22/20
to Multiplayer Piano Forum
This is no longer necessary; the original script now adds the origin header when used in node.js
Message has been deleted
Message has been deleted

August Berchelmann

unread,
Oct 23, 2020, 4:50:00 PM10/23/20
to mpp-...@googlegroups.com
You're using an outdated client. the new WS address is wss://www.multiplayerpiano.com:443

On Fri, Oct 23, 2020 at 4:48 PM Habib Aina <habib...@gmail.com> wrote:

this is the log file but it's not accessing the proxy. What am I doing wrong here?
--
You received this message because you are subscribed to the Google Groups "Multiplayer Piano Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mpp-forum+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mpp-forum/5de1e8da-2623-4c11-9b70-bb2f4c3e18f8n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages