bfg-common 1.0.29 → 1.0.31

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.
Files changed (26) hide show
  1. package/assets/localization/local_be.json +160 -1
  2. package/assets/localization/local_en.json +161 -1
  3. package/assets/localization/local_hy.json +160 -1
  4. package/assets/localization/local_kk.json +160 -1
  5. package/assets/localization/local_ru.json +161 -1
  6. package/assets/localization/local_zh.json +160 -1
  7. package/components/common/monitor/advanced/Advanced.vue +33 -18
  8. package/components/common/monitor/advanced/GraphView.vue +78 -146
  9. package/components/common/monitor/advanced/tools/Tools.vue +41 -20
  10. package/components/common/monitor/advanced/tools/chartOptionsModal/ChartOptionsModal.vue +35 -19
  11. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/Counters.vue +22 -21
  12. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/Table.vue +44 -35
  13. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/config/tableConfig.ts +13 -15
  14. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/config/utils.ts +634 -0
  15. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/models/interfaces.ts +19 -6
  16. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/models/types.ts +3 -5
  17. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/Timespan.vue +4 -1
  18. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/form/Form.vue +8 -15
  19. package/components/common/monitor/advanced/tools/chartOptionsModal/metrics/Metrics.vue +18 -8
  20. package/components/common/monitor/advanced/tools/chartOptionsModal/metrics/config/optionsMetrics.ts +52 -58
  21. package/components/common/monitor/advanced/tools/chartOptionsModal/models/types.ts +3 -0
  22. package/components/common/monitor/models/interfaces.ts +2 -0
  23. package/package.json +1 -1
  24. package/public/spice-console/application/application.js +1 -1
  25. package/public/spice-console/network/spicechannel.js +346 -287
  26. package/public/spice-console-minify/application/application.min.js +1 -1
@@ -20,291 +20,350 @@
20
20
  //Must fire event types: connectionId and message
21
21
 
22
22
  wdi.SpiceChannel = $.spcExtend(wdi.EventObject.prototype, {
23
- counter: 0,
24
- ackWindow: 0,
25
- connectionId: 0,
26
- socketQ: null,
27
- packetReassembler: null,
28
- channel: 1,
29
- codec: wdi.SpiceVideoCodecType.SPICE_VIDEO_CODEC_TYPE_MJPEG,
30
- proxy: null,
31
- token: null,
32
-
33
- init: function(c) {
34
- this.superInit();
35
- this.socketQ = c.socketQ || new wdi.SocketQueue();
36
- this.packetReassembler = c.packetReassembler || wdi.ReassemblerFactory.getPacketReassembler(this.socketQ);
37
- this.setListeners();
38
- this.ackWindow = 0;
39
- },
40
-
41
- startHandshakeTimeout: function () {
42
- var self = this;
43
- this.handshakeTimeout = window.setTimeout(function () {
44
- var err = new Error("Handshake timeout");
45
- err.code = 4200;
46
- wdi.Debug.error("Handshake timeout reached, raising error");
47
- self.fire('error', err);
48
- }, 5000);
49
- },
50
-
51
- cancelHandshakeTimeout: function () {
52
- clearTimeout(this.handshakeTimeout);
53
- },
54
-
55
- setListeners: function() {
56
- var date;
57
- var self = this;
58
- this.packetReassembler.addListener('packetComplete', function(e) {
59
- var rawMessage = e;
60
- if (rawMessage.status === 'spicePacket') {
61
- wdi.Debug.log('packetComplete spicePacket');
62
- self.cancelHandshakeTimeout();
63
- if (wdi.logOperations) {
64
- wdi.DataLogger.logNetworkTime();
65
- date = Date.now();
66
- }
67
- var rsm = this.getRawSpiceMessage(rawMessage.data);
68
- if (rsm) {
69
- if (wdi.logOperations && rsm.channel === wdi.SpiceVars.SPICE_CHANNEL_DISPLAY) {
70
- wdi.DataLogger.setStartTime(date);
71
- }
72
- this.fire('message', rsm);
73
- }
74
- } else if (rawMessage.status === 'reply') {
75
- wdi.Debug.log('packetComplete reply');
76
- var packet = this.getRedLinkReplyBytes(rawMessage.data);
77
- this.send(packet);
78
- } else if (rawMessage.status === 'errorCode') {
79
- wdi.Debug.log('packetComplete errorCode');
80
- var packet = this.getErrorCodeBytes(rawMessage.data);
81
- if (packet) {
82
- this.send(packet);
83
- if (this.channel === wdi.SpiceVars.SPICE_CHANNEL_DISPLAY) {
84
- // Custom code
85
- // Set codec
86
- this.changeCodec(this.codec)
87
- // Custom code end
88
- }
89
- }
90
- this.fire('channelConnected');
91
- }
92
- }, this);
93
-
94
- this.socketQ.addListener('open', function() {
95
- var packet = this.getRedLinkMessBytes();
96
- this.send(packet);
97
- this.proxy ? this.proxy.end() : false;
98
- }, this);
99
-
100
- this.socketQ.addListener('close', function(e) {
101
- if (this.channel === 1) {
102
- this.fire('error', e);
103
- }
104
- this.socketQ.disconnect();
105
- }, this);
106
-
107
- this.socketQ.addListener('error', function(e) {
108
- this.fire('error', e);
109
- this.socketQ.disconnect();
110
- }, this);
111
- },
112
-
113
- changeCodec: function (codec) {
114
-
115
- this.sendObject([
116
- ...wdi.SpiceObject.numberTo16(2),
117
- ...wdi.SpiceObject.numberTo16(codec),
118
- ...wdi.SpiceObject.numberTo16(3)
119
- ], wdi.SpiceVars.SPICE_MSGC_DISPLAY_PREFERRED_VIDEO_CODEC_TYPE)
120
-
121
- wdi.currentCodec = codec
122
-
123
- console.log(`codec changed: ${codec}`);
124
- },
125
-
126
- connect: function(connectionInfo, channel, connectionId, proxy) {
127
- var url = wdi.Utils.generateWebSocketUrl(connectionInfo.protocol, connectionInfo.host, connectionInfo.port, connectionInfo.vmHost, connectionInfo.vmPort, 'spice', connectionInfo.vmInfoToken, connectionInfo.vmid);
128
- this.channel = channel;
129
- this.connectionId = connectionId || 0;
130
- this.socketQ.connect(url);
131
- this.startHandshakeTimeout();
132
- this.proxy = proxy;
133
- this.token = connectionInfo.token;
134
- this.packetReassembler.start();
135
- },
136
-
137
- disconnect: function () {
138
- wdi.Debug.log('spicechannel disconnect');
139
- this.counter = 0;
140
- this.ackWindow = 0;
141
- this.connectionId = 0;
142
- this.socketQ.disconnect();
143
- this.socketQ = null;
144
- this.packetReassembler.dispose();
145
- this.packetReassembler = null;
146
- this.channel = 1;
147
- this.proxy = null;
148
- this.token = null;
149
- },
150
-
151
- send: function(data, flush) {
152
- this.socketQ.send(data, flush);
153
- },
154
-
155
- sendObject: function(data, type, flush) {
156
-
157
- // TODO: Unhardcode this value
158
- var bufSize = 2048;
159
- for (var current = 0; current < data.length; current += bufSize) {
160
- var part = data.slice(current, current + bufSize);
161
- var packet = new wdi.SpiceDataHeader({
162
- type: type,
163
- size: part.length
164
- }).marshall();
165
-
166
- packet = packet.concat(part);
167
-
168
- this.send(packet, flush);
23
+ counter: 0,
24
+ ackWindow: 0,
25
+ connectionId: 0,
26
+ socketQ: null,
27
+ packetReassembler: null,
28
+ channel: 1,
29
+ codec: wdi.SpiceVideoCodecType.SPICE_VIDEO_CODEC_TYPE_MJPEG,
30
+ proxy: null,
31
+ token: null,
32
+
33
+ init: function (c) {
34
+ this.superInit()
35
+ this.socketQ = c.socketQ || new wdi.SocketQueue()
36
+ this.packetReassembler =
37
+ c.packetReassembler ||
38
+ wdi.ReassemblerFactory.getPacketReassembler(this.socketQ)
39
+ this.setListeners()
40
+ this.ackWindow = 0
41
+ },
42
+
43
+ // startHandshakeTimeout: function () {
44
+ // var self = this
45
+ // this.handshakeTimeout = window.setTimeout(function () {
46
+ // var err = new Error('Handshake timeout')
47
+ // err.code = 4200
48
+ // wdi.Debug.error('Handshake timeout reached, raising error')
49
+ // self.fire('error', err)
50
+ // }, 5000)
51
+ // },
52
+
53
+ fireHandshakeTimeoutError: function () {
54
+ var err = new Error('Handshake timeout')
55
+ err.code = 4200
56
+ wdi.Debug.error('Handshake timeout reached, raising error')
57
+ this.fire('error', err)
58
+ },
59
+
60
+ // cancelHandshakeTimeout: function () {
61
+ // clearTimeout(this.handshakeTimeout)
62
+ // },
63
+
64
+ setListeners: function () {
65
+ var date
66
+ var self = this
67
+ this.packetReassembler.addListener(
68
+ 'packetComplete',
69
+ function (e) {
70
+ var rawMessage = e
71
+ if (rawMessage.status === 'spicePacket') {
72
+ wdi.Debug.log('packetComplete spicePacket')
73
+ // self.cancelHandshakeTimeout()
74
+ if (wdi.logOperations) {
75
+ wdi.DataLogger.logNetworkTime()
76
+ date = Date.now()
77
+ }
78
+ var rsm = this.getRawSpiceMessage(rawMessage.data)
79
+ if (rsm) {
80
+ if (
81
+ wdi.logOperations &&
82
+ rsm.channel === wdi.SpiceVars.SPICE_CHANNEL_DISPLAY
83
+ ) {
84
+ wdi.DataLogger.setStartTime(date)
85
+ }
86
+ this.fire('message', rsm)
87
+ }
88
+ } else if (rawMessage.status === 'reply') {
89
+ wdi.Debug.log('packetComplete reply')
90
+ var packet = this.getRedLinkReplyBytes(rawMessage.data)
91
+ this.send(packet)
92
+ } else if (rawMessage.status === 'errorCode') {
93
+ wdi.Debug.log('packetComplete errorCode')
94
+ var packet = this.getErrorCodeBytes(rawMessage.data)
95
+ if (packet) {
96
+ this.send(packet)
97
+ if (this.channel === wdi.SpiceVars.SPICE_CHANNEL_DISPLAY) {
98
+ // Custom code
99
+ // Set codec
100
+ this.changeCodec(this.codec)
101
+ // Custom code end
102
+ }
103
+ }
104
+ this.fire('channelConnected')
105
+ } else {
106
+ self.fireHandshakeTimeoutError()
169
107
  }
170
- },
171
-
172
- // Custom code
173
- arrayOfNumberToUint32: function (arrayOfNumber) {
174
- let v = 0;
175
- for (let n of arrayOfNumber) {
176
- v |= 1 << n;
177
- }
178
- return v
179
- },
180
- // Custom code end
181
-
182
- setAckWindow: function(window) {
183
- this.ackWindow = window;
184
- this.counter = 0;
185
- },
186
-
187
- getRawSpiceMessage: function (rawData) {
188
- var headerQueue = wdi.GlobalPool.create('ViewQueue');
189
- var body = wdi.GlobalPool.create('ViewQueue');
190
-
191
- var header = new Uint8Array(rawData, 0, wdi.SpiceDataHeader.prototype.objectSize);
192
- headerQueue.setData(header);
193
- var headerObj = new wdi.SpiceDataHeader().demarshall(headerQueue);
194
- wdi.GlobalPool.discard('ViewQueue', headerQueue);
195
- var rawBody = rawData.subarray(wdi.SpiceDataHeader.prototype.objectSize);
196
- body.setData(rawBody);
197
-
198
- this.counter++;
199
-
200
- if(this.ackWindow && this.counter === this.ackWindow) {
201
- this.counter = 0;
202
- var ack = new wdi.SpiceDataHeader({
203
- type: wdi.SpiceVars.SPICE_MSGC_ACK,
204
- size:0
205
- }).marshall();
206
- this.send(ack);
207
- }
208
-
209
- var packet = wdi.PacketLinkFactory.extract(headerObj, body) || false;
210
- if (packet) {
211
- wdi.PacketLinkProcess.process(headerObj, packet, this);
212
- wdi.GlobalPool.discard('ViewQueue', body);
213
- return false;
214
- } else {
215
- var rawSpiceMessage = wdi.GlobalPool.create('RawSpiceMessage');
216
- rawSpiceMessage.set(headerObj, body, this.channel);
217
- return rawSpiceMessage;
218
- }
219
- },
220
-
221
-
222
- //This functions are to avoid hardcoded values on logic
223
- getRedLinkReplyBytes: function(data) {
224
- if (this.token) {
225
- var newq = new wdi.ViewQueue();
226
- newq.setData(data);
227
- newq.eatBytes(wdi.SpiceLinkHeader.prototype.objectSize)
228
- var myBody = new wdi.SpiceLinkReply().demarshall(newq);
229
-
230
- //Returnnig void bytes or encrypted ticket
231
- var key = wdi.SpiceObject.stringHexToBytes(RSA_public_encrypt(this.token, myBody.pub_key));
232
- return key;
233
- } else {
234
- return wdi.SpiceObject.stringToBytesPadding('', 128);
235
- }
236
- },
237
-
238
- getRedLinkMessBytes: function() {
239
- // var header = new wdi.SpiceLinkHeader({magic:1363428690, major_version:2, minor_version:2, size:22}).marshall();
240
- // var body = new wdi.SpiceLinkMess({
241
- // connection_id:this.connectionId,
242
- // channel_type:this.channel,
243
- // caps_offset:18,
244
- // num_common_caps: 1,
245
- // num_channel_caps: 0,
246
- // common_caps: (1 << wdi.SpiceVars.SPICE_COMMON_CAP_MINI_HEADER)
247
- // }).marshall();
248
-
249
- // Custom code
250
- // TODO uncomment this code for send caps
251
- var header = new wdi.SpiceLinkHeader({magic:1363428690, major_version:2, minor_version:2, size:26}).marshall();
252
- var body = new wdi.SpiceLinkMess({
253
- connection_id:this.connectionId,
254
- channel_type:this.channel,
255
- caps_offset:18,
256
- num_common_caps: 1,
257
- num_channel_caps: 1,
258
- common_caps: (1 << wdi.SpiceVars.SPICE_COMMON_CAP_MINI_HEADER),
259
- channel_caps: this.arrayOfNumberToUint32([
260
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_SIZED_STREAM,
261
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_STREAM_REPORT,
262
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_MONITORS_CONFIG,
263
-
264
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_MULTI_CODEC,
265
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_PREF_VIDEO_CODEC_TYPE,
266
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_MJPEG,
267
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_VP8,
268
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_H264,
269
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_VP9,
270
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_H265,
271
-
272
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_LZ4_COMPRESSION,
273
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_PREF_COMPRESSION,
274
- ])
275
- }).marshall();
276
- // Custom code end
277
-
278
- return header.concat(body);
279
- },
280
-
281
- getErrorCodeBytes: function (data) {
282
- var errorQ = wdi.GlobalPool.create('ViewQueue');
283
- errorQ.setData(data);
284
- var errorCode = wdi.SpiceObject.bytesToInt32NoAllocate(errorQ);
285
- wdi.GlobalPool.discard('ViewQueue', errorQ);
286
- if (errorCode === 0) {
287
- if (this.channel === wdi.SpiceVars.SPICE_CHANNEL_DISPLAY) {
288
- var redDisplayInit = new wdi.SpiceDataHeader({type: wdi.SpiceVars.SPICE_MSGC_DISPLAY_INIT, size: 14}).marshall();
289
- //TODO: ultrahardcoded value here, move to configuration
290
-
291
- //DUE To high level storage the memory specified for cache
292
- //is 2-3 times bigger than expected.
293
- var cache_size = 1;
294
-
295
- var body = new wdi.SpiceCDisplayInit({
296
- pixmap_cache_id:1,
297
- pixmap_cache_size: cache_size,
298
- glz_dictionary_id: 0,
299
- glz_dictionary_window_size: 0
300
- }).marshall();
301
-
302
- return redDisplayInit.concat(body);
303
- } else if(this.channel == wdi.SpiceVars.SPICE_CHANNEL_MAIN) {
304
- return new wdi.SpiceDataHeader({type: wdi.SpiceVars.SPICE_MSGC_MAIN_ATTACH_CHANNELS, size: 0}).marshall();
305
- }
306
- } else {
307
- throw new wdi.Exception({message: "Server refused client", errorCode: 2});
308
- }
309
- }
310
- });
108
+ },
109
+ this
110
+ )
111
+
112
+ this.socketQ.addListener(
113
+ 'open',
114
+ function () {
115
+ var packet = this.getRedLinkMessBytes()
116
+ this.send(packet)
117
+ this.proxy ? this.proxy.end() : false
118
+ },
119
+ this
120
+ )
121
+
122
+ this.socketQ.addListener(
123
+ 'close',
124
+ function (e) {
125
+ if (this.channel === 1) {
126
+ this.fire('error', e)
127
+ }
128
+ this.socketQ.disconnect()
129
+ },
130
+ this
131
+ )
132
+
133
+ this.socketQ.addListener(
134
+ 'error',
135
+ function (e) {
136
+ this.fire('error', e)
137
+ this.socketQ.disconnect()
138
+ },
139
+ this
140
+ )
141
+ },
142
+
143
+ changeCodec: function (codec) {
144
+ this.sendObject(
145
+ [
146
+ ...wdi.SpiceObject.numberTo16(2),
147
+ ...wdi.SpiceObject.numberTo16(codec),
148
+ ...wdi.SpiceObject.numberTo16(3),
149
+ ],
150
+ wdi.SpiceVars.SPICE_MSGC_DISPLAY_PREFERRED_VIDEO_CODEC_TYPE
151
+ )
152
+
153
+ wdi.currentCodec = codec
154
+
155
+ console.log(`codec changed: ${codec}`)
156
+ },
157
+
158
+ connect: function (connectionInfo, channel, connectionId, proxy) {
159
+ var url = wdi.Utils.generateWebSocketUrl(
160
+ connectionInfo.protocol,
161
+ connectionInfo.host,
162
+ connectionInfo.port,
163
+ connectionInfo.vmHost,
164
+ connectionInfo.vmPort,
165
+ 'spice',
166
+ connectionInfo.vmInfoToken,
167
+ connectionInfo.vmid
168
+ )
169
+ this.channel = channel
170
+ this.connectionId = connectionId || 0
171
+ this.socketQ.connect(url)
172
+ // this.startHandshakeTimeout()
173
+ this.proxy = proxy
174
+ this.token = connectionInfo.token
175
+ this.packetReassembler.start()
176
+ },
177
+
178
+ disconnect: function () {
179
+ wdi.Debug.log('spicechannel disconnect')
180
+ this.counter = 0
181
+ this.ackWindow = 0
182
+ this.connectionId = 0
183
+ this.socketQ.disconnect()
184
+ this.socketQ = null
185
+ this.packetReassembler.dispose()
186
+ this.packetReassembler = null
187
+ this.channel = 1
188
+ this.proxy = null
189
+ this.token = null
190
+ },
191
+
192
+ send: function (data, flush) {
193
+ this.socketQ.send(data, flush)
194
+ },
195
+
196
+ sendObject: function (data, type, flush) {
197
+ // TODO: Unhardcode this value
198
+ var bufSize = 2048
199
+ for (var current = 0; current < data.length; current += bufSize) {
200
+ var part = data.slice(current, current + bufSize)
201
+ var packet = new wdi.SpiceDataHeader({
202
+ type: type,
203
+ size: part.length,
204
+ }).marshall()
205
+
206
+ packet = packet.concat(part)
207
+
208
+ this.send(packet, flush)
209
+ }
210
+ },
211
+
212
+ // Custom code
213
+ arrayOfNumberToUint32: function (arrayOfNumber) {
214
+ let v = 0
215
+ for (let n of arrayOfNumber) {
216
+ v |= 1 << n
217
+ }
218
+ return v
219
+ },
220
+ // Custom code end
221
+
222
+ setAckWindow: function (window) {
223
+ this.ackWindow = window
224
+ this.counter = 0
225
+ },
226
+
227
+ getRawSpiceMessage: function (rawData) {
228
+ var headerQueue = wdi.GlobalPool.create('ViewQueue')
229
+ var body = wdi.GlobalPool.create('ViewQueue')
230
+
231
+ var header = new Uint8Array(
232
+ rawData,
233
+ 0,
234
+ wdi.SpiceDataHeader.prototype.objectSize
235
+ )
236
+ headerQueue.setData(header)
237
+ var headerObj = new wdi.SpiceDataHeader().demarshall(headerQueue)
238
+ wdi.GlobalPool.discard('ViewQueue', headerQueue)
239
+ var rawBody = rawData.subarray(wdi.SpiceDataHeader.prototype.objectSize)
240
+ body.setData(rawBody)
241
+
242
+ this.counter++
243
+
244
+ if (this.ackWindow && this.counter === this.ackWindow) {
245
+ this.counter = 0
246
+ var ack = new wdi.SpiceDataHeader({
247
+ type: wdi.SpiceVars.SPICE_MSGC_ACK,
248
+ size: 0,
249
+ }).marshall()
250
+ this.send(ack)
251
+ }
252
+
253
+ var packet = wdi.PacketLinkFactory.extract(headerObj, body) || false
254
+ if (packet) {
255
+ wdi.PacketLinkProcess.process(headerObj, packet, this)
256
+ wdi.GlobalPool.discard('ViewQueue', body)
257
+ return false
258
+ } else {
259
+ var rawSpiceMessage = wdi.GlobalPool.create('RawSpiceMessage')
260
+ rawSpiceMessage.set(headerObj, body, this.channel)
261
+ return rawSpiceMessage
262
+ }
263
+ },
264
+
265
+ //This functions are to avoid hardcoded values on logic
266
+ getRedLinkReplyBytes: function (data) {
267
+ if (this.token) {
268
+ var newq = new wdi.ViewQueue()
269
+ newq.setData(data)
270
+ newq.eatBytes(wdi.SpiceLinkHeader.prototype.objectSize)
271
+ var myBody = new wdi.SpiceLinkReply().demarshall(newq)
272
+
273
+ //Returnnig void bytes or encrypted ticket
274
+ var key = wdi.SpiceObject.stringHexToBytes(
275
+ RSA_public_encrypt(this.token, myBody.pub_key)
276
+ )
277
+ return key
278
+ } else {
279
+ return wdi.SpiceObject.stringToBytesPadding('', 128)
280
+ }
281
+ },
282
+
283
+ getRedLinkMessBytes: function () {
284
+ // var header = new wdi.SpiceLinkHeader({magic:1363428690, major_version:2, minor_version:2, size:22}).marshall();
285
+ // var body = new wdi.SpiceLinkMess({
286
+ // connection_id:this.connectionId,
287
+ // channel_type:this.channel,
288
+ // caps_offset:18,
289
+ // num_common_caps: 1,
290
+ // num_channel_caps: 0,
291
+ // common_caps: (1 << wdi.SpiceVars.SPICE_COMMON_CAP_MINI_HEADER)
292
+ // }).marshall();
293
+
294
+ // Custom code
295
+ // TODO uncomment this code for send caps
296
+ var header = new wdi.SpiceLinkHeader({
297
+ magic: 1363428690,
298
+ major_version: 2,
299
+ minor_version: 2,
300
+ size: 26,
301
+ }).marshall()
302
+ var body = new wdi.SpiceLinkMess({
303
+ connection_id: this.connectionId,
304
+ channel_type: this.channel,
305
+ caps_offset: 18,
306
+ num_common_caps: 1,
307
+ num_channel_caps: 1,
308
+ common_caps: 1 << wdi.SpiceVars.SPICE_COMMON_CAP_MINI_HEADER,
309
+ channel_caps: this.arrayOfNumberToUint32([
310
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_SIZED_STREAM,
311
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_STREAM_REPORT,
312
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_MONITORS_CONFIG,
313
+
314
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_MULTI_CODEC,
315
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_PREF_VIDEO_CODEC_TYPE,
316
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_MJPEG,
317
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_VP8,
318
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_H264,
319
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_VP9,
320
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_H265,
321
+
322
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_LZ4_COMPRESSION,
323
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_PREF_COMPRESSION,
324
+ ]),
325
+ }).marshall()
326
+ // Custom code end
327
+
328
+ return header.concat(body)
329
+ },
330
+
331
+ getErrorCodeBytes: function (data) {
332
+ var errorQ = wdi.GlobalPool.create('ViewQueue')
333
+ errorQ.setData(data)
334
+ var errorCode = wdi.SpiceObject.bytesToInt32NoAllocate(errorQ)
335
+ wdi.GlobalPool.discard('ViewQueue', errorQ)
336
+ if (errorCode === 0) {
337
+ if (this.channel === wdi.SpiceVars.SPICE_CHANNEL_DISPLAY) {
338
+ var redDisplayInit = new wdi.SpiceDataHeader({
339
+ type: wdi.SpiceVars.SPICE_MSGC_DISPLAY_INIT,
340
+ size: 14,
341
+ }).marshall()
342
+ //TODO: ultrahardcoded value here, move to configuration
343
+
344
+ //DUE To high level storage the memory specified for cache
345
+ //is 2-3 times bigger than expected.
346
+ var cache_size = 1
347
+
348
+ var body = new wdi.SpiceCDisplayInit({
349
+ pixmap_cache_id: 1,
350
+ pixmap_cache_size: cache_size,
351
+ glz_dictionary_id: 0,
352
+ glz_dictionary_window_size: 0,
353
+ }).marshall()
354
+
355
+ return redDisplayInit.concat(body)
356
+ } else if (this.channel == wdi.SpiceVars.SPICE_CHANNEL_MAIN) {
357
+ return new wdi.SpiceDataHeader({
358
+ type: wdi.SpiceVars.SPICE_MSGC_MAIN_ATTACH_CHANNELS,
359
+ size: 0,
360
+ }).marshall()
361
+ }
362
+ } else {
363
+ throw new wdi.Exception({
364
+ message: 'Server refused client',
365
+ errorCode: 2,
366
+ })
367
+ }
368
+ },
369
+ })