diff --git a/tools/model_funcs.js b/tools/model_funcs.js index 3e111fd..f6e8bc5 100644 --- a/tools/model_funcs.js +++ b/tools/model_funcs.js @@ -44,8 +44,11 @@ var WSS_SERVER_PORT = 8887 var INTERFACE_PORT = 5000 var server = wss.createServer(function(conn){ + var curr_url; conn.on("text", function(info){ - if (info == 'browser:start'){ + if (info.startsWith('browser:start')){ + curr_url = info.slice(14) + console.log("connect:", new URL(curr_url).origin) global.conn = conn }else{ try{ @@ -54,8 +57,8 @@ var server = wss.createServer(function(conn){ resqueue.pop().json({message: info}) } }) - conn.on("error", function(){ console.log("error") }) - conn.on("close", function(){ console.log("close") }) + conn.on("error", function(){}) + conn.on("close", function(){ console.log("close:", new URL(curr_url).origin) }) }) server.listen(WSS_SERVER_PORT, function(){ console.log("wss start @", WSS_SERVER_PORT); @@ -168,11 +171,13 @@ function handle_proxy(req, res) { console.log(e) }); }else{ + res.writeHead(233, {'Content-type': 'text/html'}) res.write('