forked from qlik-oss/enigma.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoggle-delta.js
33 lines (29 loc) · 1.08 KB
/
toggle-delta.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const enigma = require('enigma.js');
const WebSocket = require('ws');
const schema = require('enigma.js/schemas/12.20.0.json');
const session = enigma.create({
schema,
url: 'ws://localhost:9076/app/engineData',
createSocket: url => new WebSocket(url),
requestInterceptors: [{
onFulfilled: function toggleDelta(sessionReference, request) {
// check if the request is something we want to modify:
if (request.method === 'EngineVersion' && request.handle === -1) {
// we toggle the delta protocol flag off for this request specifically:
request.delta = false;
}
return request;
},
}],
});
session.on('traffic:sent', data => console.log(`Sent: ${JSON.stringify(data)}`));
session.open()
.then(global => global.getUniqueID()
.then(result => console.log(`Unique ID: ${result}`))
.then(() => global.engineVersion())
.then(result => console.log(`Engine version: ${result.qComponentVersion}`)))
.then(() => session.close())
.catch((error) => {
console.log('Session: Failed to open socket:', error);
process.exit(1);
});