mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-11 09:24:58 +00:00
Update websocket.js
This commit is contained in:
parent
caa57b91e4
commit
41ae841177
|
@ -12,6 +12,7 @@ var FILE = require("lib/file");
|
|||
|
||||
var WebsocketObject = function() {
|
||||
this.binPath = "bin\\websocat_win64";
|
||||
this.timeout = 0;
|
||||
|
||||
this.setBinPath = function(path) {
|
||||
if (typeof(path) !== "undefined") {
|
||||
|
@ -26,6 +27,10 @@ var WebsocketObject = function() {
|
|||
}
|
||||
};
|
||||
|
||||
this.setTimeout = function(timeout) {
|
||||
this.timeout = timeout;
|
||||
};
|
||||
|
||||
this.send = function(uri, msg) {
|
||||
var seed = parseInt(Math.random() * 10000);
|
||||
var FN = "tmp\\stdin_" + seed + ".txt";
|
||||
|
@ -34,17 +39,17 @@ var WebsocketObject = function() {
|
|||
FILE.writeFile(FN, msg + "\n", "utf-8");
|
||||
console.log(msg);
|
||||
sleep(1);
|
||||
|
||||
var cmd = [this.binPath, "-n1", "-t"];
|
||||
if (this.timeout > 0) {
|
||||
cmd.push("--ping-timeout");
|
||||
cmd.push(this.timeout);
|
||||
}
|
||||
cmd.push(uri);
|
||||
cmd.push("<");
|
||||
cmd.push(FN);
|
||||
|
||||
return SHELL.exec([
|
||||
this.binPath,
|
||||
"-n1",
|
||||
"-t",
|
||||
//"--ping-timeout",
|
||||
//1,
|
||||
uri,
|
||||
"<",
|
||||
FN
|
||||
]);
|
||||
return SHELL.exec(cmd);
|
||||
} catch (e) {
|
||||
console.error("WebsocketObject.send() -> " + e.message);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user