camstreamerlib 1.8.4 → 1.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CamOverlayAPI.js +12 -0
- package/CreatePackage.js +7 -5
- package/HTTPRequest.d.ts +1 -3
- package/package.json +1 -1
package/CamOverlayAPI.js
CHANGED
|
@@ -135,10 +135,21 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
135
135
|
}
|
|
136
136
|
this.ws = new WebSocket(addr, 'cairo-api', options);
|
|
137
137
|
this.ws.binaryType = 'arraybuffer';
|
|
138
|
+
this.ws.isAlive = true;
|
|
139
|
+
const pingTimer = setInterval(() => {
|
|
140
|
+
if (this.ws.readyState !== this.ws.OPEN || this.ws.isAlive === false) {
|
|
141
|
+
return this.ws.terminate();
|
|
142
|
+
}
|
|
143
|
+
this.ws.isAlive = false;
|
|
144
|
+
this.ws.ping();
|
|
145
|
+
}, 30000);
|
|
138
146
|
this.ws.on('open', () => {
|
|
139
147
|
this.reportMsg('Websocket opened');
|
|
140
148
|
resolve();
|
|
141
149
|
});
|
|
150
|
+
this.ws.on('pong', () => {
|
|
151
|
+
this.ws.isAlive = true;
|
|
152
|
+
});
|
|
142
153
|
this.ws.on('message', (data) => {
|
|
143
154
|
let dataJSON = JSON.parse(data);
|
|
144
155
|
if (dataJSON.hasOwnProperty('call_id') && dataJSON['call_id'] in this.sendMessages) {
|
|
@@ -170,6 +181,7 @@ class CamOverlayAPI extends EventEmitter {
|
|
|
170
181
|
});
|
|
171
182
|
this.ws.on('close', () => {
|
|
172
183
|
this.reportClose();
|
|
184
|
+
clearInterval(pingTimer);
|
|
173
185
|
});
|
|
174
186
|
});
|
|
175
187
|
return promise;
|
package/CreatePackage.js
CHANGED
|
@@ -18,16 +18,18 @@ function getPackageVersion(folder) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
function createZipArchive(zip, folder, options) {
|
|
21
|
+
const zipFileRegex = new RegExp(`${Path.basename(folder)}(_[0-9]){3}\\.zip`);
|
|
21
22
|
const files = fs.readdirSync(folder);
|
|
22
23
|
for (let file of files) {
|
|
23
24
|
const path = Path.join(folder, file);
|
|
24
25
|
const isDir = isDirectory(path);
|
|
25
|
-
if (file[0]
|
|
26
|
-
(file
|
|
27
|
-
(file
|
|
26
|
+
if (file[0] === '.' ||
|
|
27
|
+
zipFileRegex.test(file) ||
|
|
28
|
+
(file === 'node_modules' && !options.includeNodeModules) ||
|
|
29
|
+
(file === 'src' && options.typeScriptPackage)) {
|
|
28
30
|
continue;
|
|
29
31
|
}
|
|
30
|
-
else if (file
|
|
32
|
+
else if (file === 'dist' && options.typeScriptPackage) {
|
|
31
33
|
zip.addLocalFolder(path);
|
|
32
34
|
}
|
|
33
35
|
else if (isDir) {
|
|
@@ -44,7 +46,7 @@ function main(args) {
|
|
|
44
46
|
typeScriptPackage: false,
|
|
45
47
|
};
|
|
46
48
|
for (let arg of args) {
|
|
47
|
-
if (arg
|
|
49
|
+
if (arg === '-i' || arg === '-includeNodeModules') {
|
|
48
50
|
options.includeNodeModules = true;
|
|
49
51
|
}
|
|
50
52
|
}
|
package/HTTPRequest.d.ts
CHANGED
|
@@ -9,9 +9,7 @@ export declare type HttpRequestOptions = {
|
|
|
9
9
|
path?: string;
|
|
10
10
|
auth?: string;
|
|
11
11
|
timeout?: number;
|
|
12
|
-
headers?:
|
|
13
|
-
'Content-Type'?: string;
|
|
14
|
-
};
|
|
12
|
+
headers?: any;
|
|
15
13
|
rejectUnauthorized?: boolean;
|
|
16
14
|
};
|
|
17
15
|
export declare function httpRequest(options: HttpRequestOptions, postData?: Buffer | string, noWaitForData?: boolean): Promise<string | http.IncomingMessage>;
|