mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-09 13:16:05 +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() {
|
var WebsocketObject = function() {
|
||||||
this.binPath = "bin\\websocat_win64";
|
this.binPath = "bin\\websocat_win64";
|
||||||
|
this.timeout = 0;
|
||||||
|
|
||||||
this.setBinPath = function(path) {
|
this.setBinPath = function(path) {
|
||||||
if (typeof(path) !== "undefined") {
|
if (typeof(path) !== "undefined") {
|
||||||
|
@ -26,6 +27,10 @@ var WebsocketObject = function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.setTimeout = function(timeout) {
|
||||||
|
this.timeout = timeout;
|
||||||
|
};
|
||||||
|
|
||||||
this.send = function(uri, msg) {
|
this.send = function(uri, msg) {
|
||||||
var seed = parseInt(Math.random() * 10000);
|
var seed = parseInt(Math.random() * 10000);
|
||||||
var FN = "tmp\\stdin_" + seed + ".txt";
|
var FN = "tmp\\stdin_" + seed + ".txt";
|
||||||
|
@ -35,16 +40,16 @@ var WebsocketObject = function() {
|
||||||
console.log(msg);
|
console.log(msg);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
return SHELL.exec([
|
var cmd = [this.binPath, "-n1", "-t"];
|
||||||
this.binPath,
|
if (this.timeout > 0) {
|
||||||
"-n1",
|
cmd.push("--ping-timeout");
|
||||||
"-t",
|
cmd.push(this.timeout);
|
||||||
//"--ping-timeout",
|
}
|
||||||
//1,
|
cmd.push(uri);
|
||||||
uri,
|
cmd.push("<");
|
||||||
"<",
|
cmd.push(FN);
|
||||||
FN
|
|
||||||
]);
|
return SHELL.exec(cmd);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("WebsocketObject.send() -> " + e.message);
|
console.error("WebsocketObject.send() -> " + e.message);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user