Compare commits

...

5 Commits

Author SHA1 Message Date
Lamp bdfbe4039f 2018-09-04 11:23:49 -07:00
Lamp a3b1dad19c 2018-09-03 14:08:32 -07:00
Lamp dad9bbe397 2018-08-25 22:04:01 -07:00
Lamp a6faa23441 2018-08-25 21:48:06 -07:00
Lamp 317de92eb6 2018-07-30 15:05:03 -07:00
2 changed files with 23 additions and 18 deletions

View File

@ -1,35 +1,26 @@
var nmpb_id = "561738578bfc6a71d8c9a907";
var output_channel = "lobby";
var input_channel = "NMPB Autoplayer (Troll Heaven2)";
var input_channel = "NMPB Autoplayer (Sockets)"; // damn Prince Fluff in Troll Heaven2
var my_name = "NMPB (Ray890)*";
var mppUri = "ws://mpp-proxy-mpp-proxy.a3c1.starter-us-west-1.openshiftapps.com:80";
var mppUri = "ws://www.multiplayerpiano.com:8080";
var Client = require('mpp-client');
var client1 = new Client(mppUri);
client1.setChannel(output_channel);
client1.start();
var client2 = new Client(mppUri);
client2.setChannel(input_channel);
function startClients() {
client1.start();
setTimeout(function(){
client2.start();
}, 2000);
}
startClients();
client2.start();
client1.on("hi", function(){
client1.sendArray([{m:'userset', set:{name:my_name}}]);
});
client1.on("disconnect", function(){
client1.stop();
client2.stop();
setTimeout(()=>{
startClients();
}, 5000);
});
setInterval(()=>{
if ((client1.isConnected() && !client1.channel) || (client1.channel && client1.channel._id != output_channel)) client1.setChannel(output_channel);
if ((client2.isConnected() && !client2.channel) || (client2.channel && client2.channel._id != input_channel )) client2.setChannel(input_channel );
}, 1000);
// NMPB notes to lobby
@ -42,12 +33,18 @@ client2.on('a', msg => {
if (msg.p._id != nmpb_id) return;
client1.sendArray([{m:'a', message: msg.a}]);
});
// NMPB mouse to lobby
client2.on('m', msg => {
if (client2.findParticipantById(msg.id)._id != nmpb_id) return;
client1.sendArray([msg]);
});
// lobby commands to NMPB
var NMPB_commands = `
help h list search s title color info about
upload u
auto a play p stop random r restart rr set pos sustain
auto a play p random r restart rr set pos sustain
backwards b mistakes tempo speed inverse mirror octave oct echo transpose tp
`.trim().split('\n').join(' ').split(' ');
client1.on('a', msg => {

8
package.json Normal file
View File

@ -0,0 +1,8 @@
{
"dependencies": {
"mpp-client": "^0.2.1"
},
"scripts": {
"start": "node nmpb-mirror.js"
}
}