mirror of
https://github.com/gnh1201/welsonjs.git
synced 2024-11-26 15:31:42 +00:00
Update websocket.js
This commit is contained in:
parent
124ea0ae30
commit
ce440ae7f7
|
@ -6,24 +6,24 @@
|
|||
// - https://stackoverflow.com/questions/52783655/use-curl-with-chrome-remote-debugging
|
||||
// - https://github.com/vi/websocat
|
||||
//
|
||||
|
||||
var SHELL = require("lib/shell");
|
||||
var SYS = require("lib/system");
|
||||
var FILE = require("lib/file");
|
||||
|
||||
var WebsocketObject = function() {
|
||||
this.binPath = "bin\\websocat_win64";
|
||||
this.timeout = 0;
|
||||
this._interface = null;
|
||||
|
||||
this.timeout = 0;
|
||||
|
||||
this.setBinPath = function(path) {
|
||||
if (typeof(path) !== "undefined") {
|
||||
this.binPath = path;
|
||||
this._interface.setPrefix(path);
|
||||
} else {
|
||||
var arch = SYS.getArch();
|
||||
if(arch.indexOf("64") > -1) {
|
||||
this.binPath = "bin\\x64\\websocat.x86_64-pc-windows-gnu.exe";
|
||||
this._interface.setPrefix("bin\\x64\\websocat.x86_64-pc-windows-gnu.exe");
|
||||
} else {
|
||||
this.binPath = "bin\\x86\\websocat.i686-pc-windows-gnu.exe";
|
||||
this._interface.setPrefix("bin\\x86\\websocat.i686-pc-windows-gnu.exe");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -41,7 +41,7 @@ var WebsocketObject = function() {
|
|||
console.log(msg);
|
||||
sleep(1);
|
||||
|
||||
var cmd = [this.binPath, "-n1", "-t"];
|
||||
var cmd = ["-n1", "-t"];
|
||||
if (this.timeout > 0) {
|
||||
cmd.push("--ping-timeout");
|
||||
cmd.push(this.timeout);
|
||||
|
@ -50,7 +50,7 @@ var WebsocketObject = function() {
|
|||
cmd.push("<");
|
||||
cmd.push(FN);
|
||||
|
||||
return SHELL.exec(cmd);
|
||||
return this._interface.exec(cmd);
|
||||
} catch (e) {
|
||||
console.error("WebsocketObject.send() -> " + e.message);
|
||||
}
|
||||
|
@ -59,13 +59,14 @@ var WebsocketObject = function() {
|
|||
};
|
||||
|
||||
this.create = function() {
|
||||
this._interface = SHELL.create();
|
||||
this.setBinPath();
|
||||
};
|
||||
|
||||
this.create();
|
||||
};
|
||||
|
||||
exports.VERSIONINFO = "Websocket Lib (websocket.js) version 0.2.2";
|
||||
exports.VERSIONINFO = "Websocket Interface (websocket.js) version 0.2.3";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user