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
|
@ -1,29 +1,29 @@
|
||||||
// Websocket API for WelsonJS framework
|
// Websocket API for WelsonJS framework
|
||||||
// Namhyeon Go <abuse@catswords.net>
|
// Namhyeon Go <abuse@catswords.net>
|
||||||
// https://github.com/gnh1201/welsonjs
|
// https://github.com/gnh1201/welsonjs
|
||||||
//
|
//
|
||||||
// references:
|
// references:
|
||||||
// - https://stackoverflow.com/questions/52783655/use-curl-with-chrome-remote-debugging
|
// - https://stackoverflow.com/questions/52783655/use-curl-with-chrome-remote-debugging
|
||||||
// - https://github.com/vi/websocat
|
// - https://github.com/vi/websocat
|
||||||
//
|
//
|
||||||
|
|
||||||
var SHELL = require("lib/shell");
|
var SHELL = require("lib/shell");
|
||||||
var SYS = require("lib/system");
|
var SYS = require("lib/system");
|
||||||
var FILE = require("lib/file");
|
var FILE = require("lib/file");
|
||||||
|
|
||||||
var WebsocketObject = function() {
|
var WebsocketObject = function() {
|
||||||
this.binPath = "bin\\websocat_win64";
|
this._interface = null;
|
||||||
this.timeout = 0;
|
|
||||||
|
this.timeout = 0;
|
||||||
|
|
||||||
this.setBinPath = function(path) {
|
this.setBinPath = function(path) {
|
||||||
if (typeof(path) !== "undefined") {
|
if (typeof(path) !== "undefined") {
|
||||||
this.binPath = path;
|
this._interface.setPrefix(path);
|
||||||
} else {
|
} else {
|
||||||
var arch = SYS.getArch();
|
var arch = SYS.getArch();
|
||||||
if(arch.indexOf("64") > -1) {
|
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 {
|
} else {
|
||||||
this.binPath = "bin\\x86\\websocat.i686-pc-windows-gnu.exe";
|
this._interface.setPrefix("bin\\x86\\websocat.i686-pc-windows-gnu.exe");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -40,8 +40,8 @@ var WebsocketObject = function() {
|
||||||
FILE.writeFile(FN, msg + "\n", FILE.CdoCharset.CdoUTF_8);
|
FILE.writeFile(FN, msg + "\n", FILE.CdoCharset.CdoUTF_8);
|
||||||
console.log(msg);
|
console.log(msg);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
var cmd = [this.binPath, "-n1", "-t"];
|
var cmd = ["-n1", "-t"];
|
||||||
if (this.timeout > 0) {
|
if (this.timeout > 0) {
|
||||||
cmd.push("--ping-timeout");
|
cmd.push("--ping-timeout");
|
||||||
cmd.push(this.timeout);
|
cmd.push(this.timeout);
|
||||||
|
@ -50,7 +50,7 @@ var WebsocketObject = function() {
|
||||||
cmd.push("<");
|
cmd.push("<");
|
||||||
cmd.push(FN);
|
cmd.push(FN);
|
||||||
|
|
||||||
return SHELL.exec(cmd);
|
return this._interface.exec(cmd);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("WebsocketObject.send() -> " + e.message);
|
console.error("WebsocketObject.send() -> " + e.message);
|
||||||
}
|
}
|
||||||
|
@ -59,13 +59,14 @@ var WebsocketObject = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.create = function() {
|
this.create = function() {
|
||||||
|
this._interface = SHELL.create();
|
||||||
this.setBinPath();
|
this.setBinPath();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.create();
|
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.global = global;
|
||||||
exports.require = global.require;
|
exports.require = global.require;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user