fix password not updating on server
This commit is contained in:
@@ -25,8 +25,6 @@ fplay.server = http.createServer(function(req, res){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
fplay.wss = new WebSocketServer({ server: fplay.server, path: "/" + fplay.PASSWORD });
|
|
||||||
|
|
||||||
fplay.seqid = 0;
|
fplay.seqid = 0;
|
||||||
fplay.pending = new Map(); // promise map
|
fplay.pending = new Map(); // promise map
|
||||||
fplay.pending_dom_ready = new Map();
|
fplay.pending_dom_ready = new Map();
|
||||||
@@ -509,43 +507,6 @@ fplay.event.on("web_request", function(page){
|
|||||||
|
|
||||||
fplay.browser_connected = false;
|
fplay.browser_connected = false;
|
||||||
|
|
||||||
fplay.wss.on("connection", async function(ws){
|
|
||||||
|
|
||||||
fplay.browser_connected = true;
|
|
||||||
fplay.event.emit("browser_connect", ws);
|
|
||||||
|
|
||||||
// register user events
|
|
||||||
ws.on("message", async function(msg){
|
|
||||||
|
|
||||||
msg = JSON.parse(msg.toString());
|
|
||||||
|
|
||||||
//console.log(msg);
|
|
||||||
|
|
||||||
if(typeof msg.seqid == "number"){
|
|
||||||
|
|
||||||
// resolve promises
|
|
||||||
fplay.pending.get(msg.seqid).resolve(msg);
|
|
||||||
fplay.pending.delete(msg.seqid);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(msg.action == "web_response"){
|
|
||||||
|
|
||||||
// decode base64 as a buffer
|
|
||||||
msg.data.body = Buffer.from(msg.data.body, "base64");
|
|
||||||
}
|
|
||||||
|
|
||||||
// any other message should be an unsolicited event
|
|
||||||
fplay.event.emit(msg.action, msg.data);
|
|
||||||
});
|
|
||||||
|
|
||||||
ws.on("close", async function(){
|
|
||||||
|
|
||||||
fplay.browser_connected = false;
|
|
||||||
fplay.event.emit("browser_disconnect", {});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
fplay.init = function(port = 3030, password = "cnc", command_timeout = 5000){
|
fplay.init = function(port = 3030, password = "cnc", command_timeout = 5000){
|
||||||
|
|
||||||
fplay.PORT = port;
|
fplay.PORT = port;
|
||||||
@@ -554,6 +515,45 @@ fplay.init = function(port = 3030, password = "cnc", command_timeout = 5000){
|
|||||||
|
|
||||||
fplay.server.listen(fplay.PORT, function(){
|
fplay.server.listen(fplay.PORT, function(){
|
||||||
|
|
||||||
|
fplay.wss = new WebSocketServer({ server: fplay.server, path: "/" + fplay.PASSWORD });
|
||||||
|
|
||||||
|
fplay.wss.on("connection", async function(ws){
|
||||||
|
|
||||||
|
fplay.browser_connected = true;
|
||||||
|
fplay.event.emit("browser_connect", ws);
|
||||||
|
|
||||||
|
// register user events
|
||||||
|
ws.on("message", async function(msg){
|
||||||
|
|
||||||
|
msg = JSON.parse(msg.toString());
|
||||||
|
|
||||||
|
//console.log(msg);
|
||||||
|
|
||||||
|
if(typeof msg.seqid == "number"){
|
||||||
|
|
||||||
|
// resolve promises
|
||||||
|
fplay.pending.get(msg.seqid).resolve(msg);
|
||||||
|
fplay.pending.delete(msg.seqid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(msg.action == "web_response"){
|
||||||
|
|
||||||
|
// decode base64 as a buffer
|
||||||
|
msg.data.body = Buffer.from(msg.data.body, "base64");
|
||||||
|
}
|
||||||
|
|
||||||
|
// any other message should be an unsolicited event
|
||||||
|
fplay.event.emit(msg.action, msg.data);
|
||||||
|
});
|
||||||
|
|
||||||
|
ws.on("close", async function(){
|
||||||
|
|
||||||
|
fplay.browser_connected = false;
|
||||||
|
fplay.event.emit("browser_disconnect", {});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
fplay.event.emit("server_ready", {});
|
fplay.event.emit("server_ready", {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user