This commit is contained in:
parent
9104f373ec
commit
1cc1dcba78
52
nmpb-pipe.js
52
nmpb-pipe.js
@ -2,35 +2,51 @@ var MPPclient = require('./Client.js');
|
||||
|
||||
var client1 = new MPPclient("ws://www.multiplayerpiano.com:443");
|
||||
client1.setChannel('NMPB Autoplayer (Sockets)');
|
||||
client1.start();
|
||||
|
||||
var client2 = new MPPclient("ws://www.multiplayerpiano.com:443");
|
||||
client2.setChannel('lobby');
|
||||
setTimeout(function(){
|
||||
client2.start();
|
||||
}, 2000);
|
||||
|
||||
client1.on('n', msg => {
|
||||
if (client1.findParticipantById(msg.p)._id != "561738578bfc6a71d8c9a907") return;
|
||||
client2.sendArray([msg]);
|
||||
|
||||
|
||||
function connectClients() {
|
||||
client1.start();
|
||||
setTimeout(function(){
|
||||
client2.start();
|
||||
}, 2000);
|
||||
}
|
||||
connectClients();
|
||||
|
||||
client1.on("disconnect", function(){
|
||||
client1.stop();
|
||||
client2.stop();
|
||||
setTimeout(()=>{
|
||||
connectClients();
|
||||
}, 5000);
|
||||
});
|
||||
|
||||
|
||||
|
||||
client1.on('n', msg => {
|
||||
if (client1.findParticipantById(msg.p)._id != "561738578bfc6a71d8c9a907") return;
|
||||
client2.sendArray([msg]);
|
||||
});
|
||||
|
||||
var cst;
|
||||
client1.on('a', msg => {
|
||||
if (msg.p._id != "561738578bfc6a71d8c9a907") return;
|
||||
if (msg.a.startsWith("Reading file Id") || msg.a.startsWith("Tempo")) { //todo tempo time is total time regardless of current position soo...
|
||||
if (msg.a.endsWith('.')) msg.a = msg.a.slice(0,-1);
|
||||
var t = msg.a.slice(-5, -1).split(':');
|
||||
var ms = (t[0]*60000)+(t[1]*1000);
|
||||
if (cst) clearTimeout(cst);
|
||||
cst = setTimeout(function(){
|
||||
client1.sendArray([{m:'a', message:"/r"}]);
|
||||
}, ms);
|
||||
}
|
||||
if (msg.p._id != "561738578bfc6a71d8c9a907") return;
|
||||
if (msg.a.startsWith("Reading file Id") || msg.a.startsWith("Tempo")) { //todo tempo time is total time regardless of current position soo...
|
||||
if (msg.a.endsWith('.')) msg.a = msg.a.slice(0,-1);
|
||||
var t = msg.a.slice(-5, -1).split(':');
|
||||
var ms = (t[0]*60000)+(t[1]*1000);
|
||||
if (cst) clearTimeout(cst);
|
||||
cst = setTimeout(function(){
|
||||
client1.sendArray([{m:'a', message:"/r"}]);
|
||||
}, ms);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
setInterval(function(){
|
||||
client1.sendArray([{m:'a', message:"/r"}]);
|
||||
client1.sendArray([{m:'a', message:"/r"}]);
|
||||
}, 1000*60*30) // just in case
|
Loading…
x
Reference in New Issue
Block a user