Compare commits
5 Commits
c283ee3139
...
bdfbe4039f
Author | SHA1 | Date | |
---|---|---|---|
|
bdfbe4039f | ||
|
a3b1dad19c | ||
|
dad9bbe397 | ||
|
a6faa23441 | ||
|
317de92eb6 |
@ -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
8
package.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"mpp-client": "^0.2.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node nmpb-mirror.js"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user