@illgrenoble/webx-client 0.1.1
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/LICENSE +674 -0
- package/README.md +8 -0
- package/dist/WebXClient.d.ts +94 -0
- package/dist/WebXClient.js +302 -0
- package/dist/WebXClient.js.map +1 -0
- package/dist/display/WebXCursor.d.ts +28 -0
- package/dist/display/WebXCursor.js +94 -0
- package/dist/display/WebXCursor.js.map +1 -0
- package/dist/display/WebXCursorFactory.d.ts +18 -0
- package/dist/display/WebXCursorFactory.js +36 -0
- package/dist/display/WebXCursorFactory.js.map +1 -0
- package/dist/display/WebXDisplay.d.ts +70 -0
- package/dist/display/WebXDisplay.js +248 -0
- package/dist/display/WebXDisplay.js.map +1 -0
- package/dist/display/WebXSubImage.d.ts +19 -0
- package/dist/display/WebXSubImage.js +20 -0
- package/dist/display/WebXSubImage.js.map +1 -0
- package/dist/display/WebXTextureFactory.d.ts +14 -0
- package/dist/display/WebXTextureFactory.js +101 -0
- package/dist/display/WebXTextureFactory.js.map +1 -0
- package/dist/display/WebXWindow.d.ts +59 -0
- package/dist/display/WebXWindow.js +205 -0
- package/dist/display/WebXWindow.js.map +1 -0
- package/dist/display/WebXWindowProperties.d.ts +14 -0
- package/dist/display/WebXWindowProperties.js +17 -0
- package/dist/display/WebXWindowProperties.js.map +1 -0
- package/dist/display/index.d.ts +7 -0
- package/dist/display/index.js +24 -0
- package/dist/display/index.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/input/WebXKeyboard.d.ts +230 -0
- package/dist/input/WebXKeyboard.js +593 -0
- package/dist/input/WebXKeyboard.js.map +1 -0
- package/dist/input/WebXMouse.d.ts +97 -0
- package/dist/input/WebXMouse.js +205 -0
- package/dist/input/WebXMouse.js.map +1 -0
- package/dist/input/index.d.ts +4 -0
- package/dist/input/index.js +21 -0
- package/dist/input/index.js.map +1 -0
- package/dist/input/keyboard/WebXKeyEvent.d.ts +47 -0
- package/dist/input/keyboard/WebXKeyEvent.js +212 -0
- package/dist/input/keyboard/WebXKeyEvent.js.map +1 -0
- package/dist/input/keyboard/WebXKeyPressEvent.d.ts +13 -0
- package/dist/input/keyboard/WebXKeyPressEvent.js +26 -0
- package/dist/input/keyboard/WebXKeyPressEvent.js.map +1 -0
- package/dist/input/keyboard/WebXKeyUpEvent.d.ts +12 -0
- package/dist/input/keyboard/WebXKeyUpEvent.js +28 -0
- package/dist/input/keyboard/WebXKeyUpEvent.js.map +1 -0
- package/dist/input/keyboard/WebXKeyboardModifierState.d.ts +47 -0
- package/dist/input/keyboard/WebXKeyboardModifierState.js +87 -0
- package/dist/input/keyboard/WebXKeyboardModifierState.js.map +1 -0
- package/dist/input/keyboard/WebXKeyboardUtils.d.ts +9 -0
- package/dist/input/keyboard/WebXKeyboardUtils.js +48 -0
- package/dist/input/keyboard/WebXKeyboardUtils.js.map +1 -0
- package/dist/input/keyboard/WebXKeydownEvent.d.ts +29 -0
- package/dist/input/keyboard/WebXKeydownEvent.js +71 -0
- package/dist/input/keyboard/WebXKeydownEvent.js.map +1 -0
- package/dist/input/keyboard/index.d.ts +6 -0
- package/dist/input/keyboard/index.js +23 -0
- package/dist/input/keyboard/index.js.map +1 -0
- package/dist/input/mouse/WebXMouseState.d.ts +78 -0
- package/dist/input/mouse/WebXMouseState.js +104 -0
- package/dist/input/mouse/WebXMouseState.js.map +1 -0
- package/dist/input/mouse/index.d.ts +1 -0
- package/dist/input/mouse/index.js +18 -0
- package/dist/input/mouse/index.js.map +1 -0
- package/dist/instruction/WebXConnectInstruction.d.ts +4 -0
- package/dist/instruction/WebXConnectInstruction.js +12 -0
- package/dist/instruction/WebXConnectInstruction.js.map +1 -0
- package/dist/instruction/WebXCursorImageInstruction.d.ts +6 -0
- package/dist/instruction/WebXCursorImageInstruction.js +16 -0
- package/dist/instruction/WebXCursorImageInstruction.js.map +1 -0
- package/dist/instruction/WebXImageInstruction.d.ts +7 -0
- package/dist/instruction/WebXImageInstruction.js +19 -0
- package/dist/instruction/WebXImageInstruction.js.map +1 -0
- package/dist/instruction/WebXInstruction.d.ts +13 -0
- package/dist/instruction/WebXInstruction.js +34 -0
- package/dist/instruction/WebXInstruction.js.map +1 -0
- package/dist/instruction/WebXInstructionResponse.d.ts +13 -0
- package/dist/instruction/WebXInstructionResponse.js +40 -0
- package/dist/instruction/WebXInstructionResponse.js.map +1 -0
- package/dist/instruction/WebXInstructionType.d.ts +13 -0
- package/dist/instruction/WebXInstructionType.js +38 -0
- package/dist/instruction/WebXInstructionType.js.map +1 -0
- package/dist/instruction/WebXKeyboardInstruction.d.ts +10 -0
- package/dist/instruction/WebXKeyboardInstruction.js +26 -0
- package/dist/instruction/WebXKeyboardInstruction.js.map +1 -0
- package/dist/instruction/WebXMouseInstruction.d.ts +13 -0
- package/dist/instruction/WebXMouseInstruction.js +33 -0
- package/dist/instruction/WebXMouseInstruction.js.map +1 -0
- package/dist/instruction/WebXQualityInstruction.d.ts +7 -0
- package/dist/instruction/WebXQualityInstruction.js +19 -0
- package/dist/instruction/WebXQualityInstruction.js.map +1 -0
- package/dist/instruction/WebXScreenInstruction.d.ts +4 -0
- package/dist/instruction/WebXScreenInstruction.js +12 -0
- package/dist/instruction/WebXScreenInstruction.js.map +1 -0
- package/dist/instruction/WebXWindowsInstruction.d.ts +4 -0
- package/dist/instruction/WebXWindowsInstruction.js +12 -0
- package/dist/instruction/WebXWindowsInstruction.js.map +1 -0
- package/dist/instruction/index.d.ts +11 -0
- package/dist/instruction/index.js +28 -0
- package/dist/instruction/index.js.map +1 -0
- package/dist/message/WebXCursorImageMessage.d.ts +17 -0
- package/dist/message/WebXCursorImageMessage.js +36 -0
- package/dist/message/WebXCursorImageMessage.js.map +1 -0
- package/dist/message/WebXImageMessage.d.ts +15 -0
- package/dist/message/WebXImageMessage.js +32 -0
- package/dist/message/WebXImageMessage.js.map +1 -0
- package/dist/message/WebXMessage.d.ts +8 -0
- package/dist/message/WebXMessage.js +17 -0
- package/dist/message/WebXMessage.js.map +1 -0
- package/dist/message/WebXMessageType.d.ts +10 -0
- package/dist/message/WebXMessageType.js +15 -0
- package/dist/message/WebXMessageType.js.map +1 -0
- package/dist/message/WebXMouseMessage.d.ts +10 -0
- package/dist/message/WebXMouseMessage.js +24 -0
- package/dist/message/WebXMouseMessage.js.map +1 -0
- package/dist/message/WebXPollMessage.d.ts +4 -0
- package/dist/message/WebXPollMessage.js +12 -0
- package/dist/message/WebXPollMessage.js.map +1 -0
- package/dist/message/WebXScreenMessage.d.ts +12 -0
- package/dist/message/WebXScreenMessage.js +16 -0
- package/dist/message/WebXScreenMessage.js.map +1 -0
- package/dist/message/WebXSubImagesMessage.d.ts +11 -0
- package/dist/message/WebXSubImagesMessage.js +24 -0
- package/dist/message/WebXSubImagesMessage.js.map +1 -0
- package/dist/message/WebXWindowsMessage.d.ts +7 -0
- package/dist/message/WebXWindowsMessage.js +16 -0
- package/dist/message/WebXWindowsMessage.js.map +1 -0
- package/dist/message/index.d.ts +9 -0
- package/dist/message/index.js +26 -0
- package/dist/message/index.js.map +1 -0
- package/dist/tracer/WebXHandler.d.ts +3 -0
- package/dist/tracer/WebXHandler.js +3 -0
- package/dist/tracer/WebXHandler.js.map +1 -0
- package/dist/tracer/WebXInstructionHandler.d.ts +4 -0
- package/dist/tracer/WebXInstructionHandler.js +7 -0
- package/dist/tracer/WebXInstructionHandler.js.map +1 -0
- package/dist/tracer/WebXMessageHandler.d.ts +4 -0
- package/dist/tracer/WebXMessageHandler.js +7 -0
- package/dist/tracer/WebXMessageHandler.js.map +1 -0
- package/dist/tracer/WebXStatsHandler.d.ts +7 -0
- package/dist/tracer/WebXStatsHandler.js +7 -0
- package/dist/tracer/WebXStatsHandler.js.map +1 -0
- package/dist/tracer/index.d.ts +4 -0
- package/dist/tracer/index.js +21 -0
- package/dist/tracer/index.js.map +1 -0
- package/dist/transport/WebXBinarySerializer.d.ts +11 -0
- package/dist/transport/WebXBinarySerializer.js +43 -0
- package/dist/transport/WebXBinarySerializer.js.map +1 -0
- package/dist/transport/WebXInstructionBuffer.d.ts +35 -0
- package/dist/transport/WebXInstructionBuffer.js +80 -0
- package/dist/transport/WebXInstructionBuffer.js.map +1 -0
- package/dist/transport/WebXInstructionEncoder.d.ts +101 -0
- package/dist/transport/WebXInstructionEncoder.js +175 -0
- package/dist/transport/WebXInstructionEncoder.js.map +1 -0
- package/dist/transport/WebXMessageBuffer.d.ts +19 -0
- package/dist/transport/WebXMessageBuffer.js +58 -0
- package/dist/transport/WebXMessageBuffer.js.map +1 -0
- package/dist/transport/WebXMessageDecoder.d.ts +16 -0
- package/dist/transport/WebXMessageDecoder.js +156 -0
- package/dist/transport/WebXMessageDecoder.js.map +1 -0
- package/dist/transport/index.d.ts +5 -0
- package/dist/transport/index.js +22 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/tunnel/WebXDefaultQoSHandler.d.ts +16 -0
- package/dist/tunnel/WebXDefaultQoSHandler.js +57 -0
- package/dist/tunnel/WebXDefaultQoSHandler.js.map +1 -0
- package/dist/tunnel/WebXQoSHandler.d.ts +6 -0
- package/dist/tunnel/WebXQoSHandler.js +7 -0
- package/dist/tunnel/WebXQoSHandler.js.map +1 -0
- package/dist/tunnel/WebXSocketIOTunnel.d.ts +15 -0
- package/dist/tunnel/WebXSocketIOTunnel.js +41 -0
- package/dist/tunnel/WebXSocketIOTunnel.js.map +1 -0
- package/dist/tunnel/WebXTunnel.d.ts +24 -0
- package/dist/tunnel/WebXTunnel.js +106 -0
- package/dist/tunnel/WebXTunnel.js.map +1 -0
- package/dist/tunnel/WebXWebSocketTunnel.d.ts +12 -0
- package/dist/tunnel/WebXWebSocketTunnel.js +41 -0
- package/dist/tunnel/WebXWebSocketTunnel.js.map +1 -0
- package/dist/tunnel/index.d.ts +5 -0
- package/dist/tunnel/index.js +22 -0
- package/dist/tunnel/index.js.map +1 -0
- package/dist/utils/Config.d.ts +4 -0
- package/dist/utils/Config.js +10 -0
- package/dist/utils/Config.js.map +1 -0
- package/dist/utils/WebXAsyncExec.d.ts +5 -0
- package/dist/utils/WebXAsyncExec.js +18 -0
- package/dist/utils/WebXAsyncExec.js.map +1 -0
- package/dist/utils/WebXColourGenerator.d.ts +5 -0
- package/dist/utils/WebXColourGenerator.js +27 -0
- package/dist/utils/WebXColourGenerator.js.map +1 -0
- package/dist/utils/WebXFileSize.d.ts +3 -0
- package/dist/utils/WebXFileSize.js +14 -0
- package/dist/utils/WebXFileSize.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +21 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebXInstructionEncoder = void 0;
|
|
4
|
+
const instruction_1 = require("../instruction");
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
class WebXInstructionEncoder {
|
|
7
|
+
/**
|
|
8
|
+
* Convert the given instruction to an array buffer ready to be sent along the wire
|
|
9
|
+
* @param instruction the instruction to encode
|
|
10
|
+
*/
|
|
11
|
+
encode(instruction) {
|
|
12
|
+
if (instruction.type === instruction_1.WebXInstructionType.MOUSE) {
|
|
13
|
+
return this._createMouseInstruction(instruction);
|
|
14
|
+
}
|
|
15
|
+
else if (instruction.type === instruction_1.WebXInstructionType.KEYBOARD) {
|
|
16
|
+
return this._createKeyboardInstruction(instruction);
|
|
17
|
+
}
|
|
18
|
+
else if (instruction.type === instruction_1.WebXInstructionType.CURSOR_IMAGE) {
|
|
19
|
+
return this._createCursorImageInstruction(instruction);
|
|
20
|
+
}
|
|
21
|
+
else if (instruction.type === instruction_1.WebXInstructionType.IMAGE) {
|
|
22
|
+
return this._createImageInstruction(instruction);
|
|
23
|
+
}
|
|
24
|
+
else if (instruction.type === instruction_1.WebXInstructionType.CONNECT) {
|
|
25
|
+
return this._createConnectInstruction(instruction);
|
|
26
|
+
}
|
|
27
|
+
else if (instruction.type === instruction_1.WebXInstructionType.SCREEN) {
|
|
28
|
+
return this._createScreenInstruction(instruction);
|
|
29
|
+
}
|
|
30
|
+
else if (instruction.type === instruction_1.WebXInstructionType.WINDOWS) {
|
|
31
|
+
return this._createWindowsInstruction(instruction);
|
|
32
|
+
}
|
|
33
|
+
else if (instruction.type === instruction_1.WebXInstructionType.QUALITY) {
|
|
34
|
+
return this._createQualityInstruction(instruction);
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create a new mouse instruction
|
|
40
|
+
* @param instruction the mouse instruction to encode
|
|
41
|
+
* Structure:
|
|
42
|
+
* Header: 24 bytes
|
|
43
|
+
* sessionId: 16 bytes
|
|
44
|
+
* type: 4 bytes
|
|
45
|
+
* id: 4 bytes
|
|
46
|
+
* Content: 4 bytes
|
|
47
|
+
* x: 4 bytes
|
|
48
|
+
* y: 4 bytes
|
|
49
|
+
* buttonMask: 4 bytes
|
|
50
|
+
*/
|
|
51
|
+
_createMouseInstruction(instruction) {
|
|
52
|
+
const encoder = new _1.WebXInstructionBuffer(instruction, 12);
|
|
53
|
+
return encoder
|
|
54
|
+
// write the contents
|
|
55
|
+
.putInt32(instruction.x)
|
|
56
|
+
.putInt32(instruction.y)
|
|
57
|
+
.putUInt32(instruction.buttonMask)
|
|
58
|
+
.buffer();
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create a new cursor image instruction
|
|
62
|
+
* @param instruction the cursor image instruction to encode
|
|
63
|
+
* Structure:
|
|
64
|
+
* Header: 24 bytes
|
|
65
|
+
* sessionId: 16 bytes
|
|
66
|
+
* type: 4 bytes
|
|
67
|
+
* id: 4 bytes
|
|
68
|
+
* Content: 4 bytes
|
|
69
|
+
* cursorId: 4 bytes
|
|
70
|
+
*/
|
|
71
|
+
_createCursorImageInstruction(instruction) {
|
|
72
|
+
const encoder = new _1.WebXInstructionBuffer(instruction, 4);
|
|
73
|
+
return encoder
|
|
74
|
+
// write the contents
|
|
75
|
+
.putInt32(instruction.cursorId)
|
|
76
|
+
.buffer();
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Create a new image instruction
|
|
80
|
+
* @param instruction the image instruction to encode
|
|
81
|
+
* Structure:
|
|
82
|
+
* Header: 24 bytes
|
|
83
|
+
* sessionId: 16 bytes
|
|
84
|
+
* type: 4 bytes
|
|
85
|
+
* id: 4 bytes
|
|
86
|
+
* Content: 4 bytes
|
|
87
|
+
* windowId: 4 bytes
|
|
88
|
+
*/
|
|
89
|
+
_createImageInstruction(instruction) {
|
|
90
|
+
const encoder = new _1.WebXInstructionBuffer(instruction, 4);
|
|
91
|
+
return encoder
|
|
92
|
+
// write the contents
|
|
93
|
+
.putUInt32(instruction.windowId)
|
|
94
|
+
.buffer();
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Create a keyboard instruction
|
|
98
|
+
* @param instruction the keyboard instruction to encode
|
|
99
|
+
* Structure:
|
|
100
|
+
* Header: 24 bytes
|
|
101
|
+
* sessionId: 16 bytes
|
|
102
|
+
* type: 4 bytes
|
|
103
|
+
* id: 4 bytes
|
|
104
|
+
* Content: 8 bytes
|
|
105
|
+
* key (the keyboard key code): 4 bytes
|
|
106
|
+
* pressed: 4 bytes
|
|
107
|
+
*/
|
|
108
|
+
_createKeyboardInstruction(instruction) {
|
|
109
|
+
const encoder = new _1.WebXInstructionBuffer(instruction, 8);
|
|
110
|
+
return encoder
|
|
111
|
+
// write the contents
|
|
112
|
+
.putUInt32(instruction.key)
|
|
113
|
+
.putBoolean(instruction.pressed)
|
|
114
|
+
.buffer();
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Create a screen instruction
|
|
118
|
+
* @param instruction the screen instruction to encode
|
|
119
|
+
* Structure:
|
|
120
|
+
* Header: 24 bytes
|
|
121
|
+
* sessionId: 16 bytes
|
|
122
|
+
* type: 4 bytes
|
|
123
|
+
* id: 4 bytes
|
|
124
|
+
*/
|
|
125
|
+
_createScreenInstruction(instruction) {
|
|
126
|
+
const encoder = new _1.WebXInstructionBuffer(instruction, 0);
|
|
127
|
+
return encoder.buffer();
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Create a windows instruction
|
|
131
|
+
* Structure:
|
|
132
|
+
* Header: 24 bytes
|
|
133
|
+
* sessionId: 16 bytes
|
|
134
|
+
* type: 4 bytes
|
|
135
|
+
* id: 4 bytes
|
|
136
|
+
* @param instruction the windows instruction to encode
|
|
137
|
+
*/
|
|
138
|
+
_createWindowsInstruction(instruction) {
|
|
139
|
+
const encoder = new _1.WebXInstructionBuffer(instruction, 0);
|
|
140
|
+
return encoder.buffer();
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Create a connect instruction
|
|
144
|
+
* @param instruction the connect instruction to encode
|
|
145
|
+
* Structure:
|
|
146
|
+
* Header: 24 bytes
|
|
147
|
+
* sessionId: 16 bytes
|
|
148
|
+
* type: 4 bytes
|
|
149
|
+
* id: 4 bytes
|
|
150
|
+
*/
|
|
151
|
+
_createConnectInstruction(instruction) {
|
|
152
|
+
const encoder = new _1.WebXInstructionBuffer(instruction, 0);
|
|
153
|
+
return encoder.buffer();
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Create a new quality instruction
|
|
157
|
+
* @param instruction the quality instruction to encode
|
|
158
|
+
* Structure:
|
|
159
|
+
* Header: 24 bytes
|
|
160
|
+
* sessionId: 16 bytes
|
|
161
|
+
* type: 4 bytes
|
|
162
|
+
* id: 4 bytes
|
|
163
|
+
* Content: 4 bytes
|
|
164
|
+
* qualityIndex: 4 bytes
|
|
165
|
+
*/
|
|
166
|
+
_createQualityInstruction(instruction) {
|
|
167
|
+
const encoder = new _1.WebXInstructionBuffer(instruction, 4);
|
|
168
|
+
return encoder
|
|
169
|
+
// write the contents
|
|
170
|
+
.putUInt32(instruction.qualityIndex)
|
|
171
|
+
.buffer();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.WebXInstructionEncoder = WebXInstructionEncoder;
|
|
175
|
+
//# sourceMappingURL=WebXInstructionEncoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebXInstructionEncoder.js","sourceRoot":"","sources":["../../src/transport/WebXInstructionEncoder.ts"],"names":[],"mappings":";;;AAAA,gDAUwB;AACxB,wBAA0C;AAG1C,MAAa,sBAAsB;IAEjC;;;OAGG;IACI,MAAM,CAAC,WAA4B;QACxC,IAAI,WAAW,CAAC,IAAI,KAAK,iCAAmB,CAAC,KAAK,EAAE;YAClD,OAAO,IAAI,CAAC,uBAAuB,CAAC,WAAmC,CAAC,CAAC;SAE1E;aAAM,IAAI,WAAW,CAAC,IAAI,KAAK,iCAAmB,CAAC,QAAQ,EAAE;YAC5D,OAAO,IAAI,CAAC,0BAA0B,CAAC,WAAsC,CAAC,CAAC;SAEhF;aAAM,IAAI,WAAW,CAAC,IAAI,KAAK,iCAAmB,CAAC,YAAY,EAAE;YAChE,OAAO,IAAI,CAAC,6BAA6B,CAAC,WAAyC,CAAC,CAAC;SAEtF;aAAM,IAAI,WAAW,CAAC,IAAI,KAAK,iCAAmB,CAAC,KAAK,EAAE;YACzD,OAAO,IAAI,CAAC,uBAAuB,CAAC,WAAmC,CAAC,CAAC;SAE1E;aAAM,IAAI,WAAW,CAAC,IAAI,KAAK,iCAAmB,CAAC,OAAO,EAAE;YAC3D,OAAO,IAAI,CAAC,yBAAyB,CAAC,WAAqC,CAAC,CAAC;SAE9E;aAAM,IAAI,WAAW,CAAC,IAAI,KAAK,iCAAmB,CAAC,MAAM,EAAE;YAC1D,OAAO,IAAI,CAAC,wBAAwB,CAAC,WAAoC,CAAC,CAAC;SAE5E;aAAM,IAAI,WAAW,CAAC,IAAI,KAAK,iCAAmB,CAAC,OAAO,EAAE;YAC3D,OAAO,IAAI,CAAC,yBAAyB,CAAC,WAAqC,CAAC,CAAC;SAE9E;aAAM,IAAI,WAAW,C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;;OAQG;IACK,wBAAwB,CAAC,WAAkC;QACjE,MAAM,OAAO,GAAG,IAAI,wBAAqB,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QAC1D,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;IAED;;;;;;;;OAQG;IACK,yBAAyB,CAAC,WAAmC;QACnE,MAAM,OAAO,GAAG,IAAI,wBAAqB,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QAC1D,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;IAED;;;;;;;;OAQG;IACK,yBAAyB,CAAC,WAAmC;QACnE,MAAM,OAAO,GAAG,IAAI,wBAAqB,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QAC1D,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;IAGD;;;;;;;;;;OAUG;IACK,yBAAyB,CAAC,WAAmC;QACnE,MAAM,OAAO,GAAG,IAAI,wBAAqB,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QAC1D,OAAO,OAAO;YACZ,qBAAqB;aACpB,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC;aACnC,MAAM,EAAE,CAAC;IACd,CAAC;CAEF;AAlLD,wDAkLC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare class WebXMessageBuffer {
|
|
2
|
+
private _buffer;
|
|
3
|
+
private readonly _messageTypeId;
|
|
4
|
+
private readonly _messageQueueLength;
|
|
5
|
+
private readonly _messageId;
|
|
6
|
+
private readonly _bufferLength;
|
|
7
|
+
private _readOffset;
|
|
8
|
+
private _encoder;
|
|
9
|
+
get messageTypeId(): number;
|
|
10
|
+
get messageQueueLength(): number;
|
|
11
|
+
get messageId(): number;
|
|
12
|
+
get bufferLength(): number;
|
|
13
|
+
constructor(_buffer: ArrayBuffer);
|
|
14
|
+
getInt32(): number;
|
|
15
|
+
getUint32(): number;
|
|
16
|
+
getUint8Array(length: number): Uint8Array;
|
|
17
|
+
getString(length: number): string;
|
|
18
|
+
private _getNextReadOffset;
|
|
19
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebXMessageBuffer = void 0;
|
|
4
|
+
class WebXMessageBuffer {
|
|
5
|
+
constructor(_buffer) {
|
|
6
|
+
this._buffer = _buffer;
|
|
7
|
+
this._readOffset = 16;
|
|
8
|
+
this._encoder = new TextDecoder('utf-8');
|
|
9
|
+
this._readOffset = 16;
|
|
10
|
+
let unused;
|
|
11
|
+
// eslint-disable-next-line
|
|
12
|
+
[this._messageTypeId, unused, this._messageQueueLength, unused] = this.getUint8Array(4);
|
|
13
|
+
this._messageId = this.getUint32();
|
|
14
|
+
this._bufferLength = this.getUint32();
|
|
15
|
+
this._readOffset = 32;
|
|
16
|
+
}
|
|
17
|
+
get messageTypeId() {
|
|
18
|
+
return this._messageTypeId;
|
|
19
|
+
}
|
|
20
|
+
get messageQueueLength() {
|
|
21
|
+
return this._messageQueueLength;
|
|
22
|
+
}
|
|
23
|
+
get messageId() {
|
|
24
|
+
return this._messageId;
|
|
25
|
+
}
|
|
26
|
+
get bufferLength() {
|
|
27
|
+
return this._bufferLength;
|
|
28
|
+
}
|
|
29
|
+
getInt32() {
|
|
30
|
+
const offset = this._getNextReadOffset(4);
|
|
31
|
+
const typedArray = new Int32Array(this._buffer, offset, 1);
|
|
32
|
+
return typedArray[0];
|
|
33
|
+
}
|
|
34
|
+
getUint32() {
|
|
35
|
+
const offset = this._getNextReadOffset(4);
|
|
36
|
+
const typedArray = new Uint32Array(this._buffer, offset, 1);
|
|
37
|
+
return typedArray[0];
|
|
38
|
+
}
|
|
39
|
+
getUint8Array(length) {
|
|
40
|
+
const typedArray = new Uint8Array(this._buffer, this._readOffset, length);
|
|
41
|
+
this._readOffset += length;
|
|
42
|
+
return typedArray;
|
|
43
|
+
}
|
|
44
|
+
getString(length) {
|
|
45
|
+
const array = new Uint8Array(this._buffer, this._readOffset, length);
|
|
46
|
+
this._readOffset += length;
|
|
47
|
+
return this._encoder.decode(array);
|
|
48
|
+
}
|
|
49
|
+
_getNextReadOffset(sizeOfData) {
|
|
50
|
+
// Ensure alignment
|
|
51
|
+
const padding = this._readOffset % sizeOfData > 0 ? sizeOfData - (this._readOffset % sizeOfData) : 0;
|
|
52
|
+
const position = this._readOffset + padding;
|
|
53
|
+
this._readOffset += sizeOfData + padding;
|
|
54
|
+
return position;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.WebXMessageBuffer = WebXMessageBuffer;
|
|
58
|
+
//# sourceMappingURL=WebXMessageBuffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebXMessageBuffer.js","sourceRoot":"","sources":["../../src/transport/WebXMessageBuffer.ts"],"names":[],"mappings":";;;AAAA,MAAa,iBAAiB;IA2B5B,YAAoB,OAAoB;QAApB,YAAO,GAAP,OAAO,CAAa;QApBhC,gBAAW,GAAW,EAAE,CAAC;QAEzB,aAAQ,GAAgB,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;QAmBvD,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,MAAM,CAAC;QACX,2BAA2B;QAC3B,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QACxF,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAxBD,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,IAAI,kBAAkB;QACpB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,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AW,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrG,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;QAE5C,IAAI,CAAC,WAAW,IAAI,UAAU,GAAG,OAAO,CAAC;QAEzC,OAAO,QAAQ,CAAC;IAClB,CAAC;CAEF;AA5ED,8CA4EC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WebXMessage } from '../message';
|
|
2
|
+
import { WebXTextureFactory } from '../display';
|
|
3
|
+
import { WebXMessageBuffer } from './WebXMessageBuffer';
|
|
4
|
+
export declare class WebXMessageDecoder {
|
|
5
|
+
private _textureFactory;
|
|
6
|
+
constructor(_textureFactory: WebXTextureFactory);
|
|
7
|
+
decode(buffer: WebXMessageBuffer): Promise<WebXMessage>;
|
|
8
|
+
private _determineMimeType;
|
|
9
|
+
private _createImageMessage;
|
|
10
|
+
private _createSubImagesMessage;
|
|
11
|
+
private _createMouseMessage;
|
|
12
|
+
private _createWindowsMessage;
|
|
13
|
+
private _createCursorImageMessage;
|
|
14
|
+
private _createScreenMessage;
|
|
15
|
+
private _createPollMessage;
|
|
16
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebXMessageDecoder = void 0;
|
|
4
|
+
const message_1 = require("../message");
|
|
5
|
+
const display_1 = require("../display");
|
|
6
|
+
class WebXMessageDecoder {
|
|
7
|
+
constructor(_textureFactory) {
|
|
8
|
+
this._textureFactory = _textureFactory;
|
|
9
|
+
}
|
|
10
|
+
decode(buffer) {
|
|
11
|
+
const { messageTypeId } = buffer;
|
|
12
|
+
if (messageTypeId === message_1.WebXMessageType.SCREEN) {
|
|
13
|
+
return this._createScreenMessage(buffer);
|
|
14
|
+
}
|
|
15
|
+
else if (messageTypeId === message_1.WebXMessageType.WINDOWS) {
|
|
16
|
+
return this._createWindowsMessage(buffer);
|
|
17
|
+
}
|
|
18
|
+
else if (messageTypeId === message_1.WebXMessageType.IMAGE) {
|
|
19
|
+
return this._createImageMessage(buffer);
|
|
20
|
+
}
|
|
21
|
+
else if (messageTypeId === message_1.WebXMessageType.SUBIMAGES) {
|
|
22
|
+
return this._createSubImagesMessage(buffer);
|
|
23
|
+
}
|
|
24
|
+
else if (messageTypeId === message_1.WebXMessageType.MOUSE) {
|
|
25
|
+
return this._createMouseMessage(buffer);
|
|
26
|
+
}
|
|
27
|
+
else if (messageTypeId === message_1.WebXMessageType.CURSOR_IMAGE) {
|
|
28
|
+
return this._createCursorImageMessage(buffer);
|
|
29
|
+
}
|
|
30
|
+
else if (messageTypeId === message_1.WebXMessageType.POLL) {
|
|
31
|
+
return this._createPollMessage();
|
|
32
|
+
}
|
|
33
|
+
console.error(`Failed to decode message with typeId ${messageTypeId}`);
|
|
34
|
+
}
|
|
35
|
+
_determineMimeType(imageType) {
|
|
36
|
+
if (imageType.substr(0, 3) === 'jpg') {
|
|
37
|
+
return 'image/jpeg';
|
|
38
|
+
}
|
|
39
|
+
else if (imageType.substr(0, 3) === 'png') {
|
|
40
|
+
return 'image/png';
|
|
41
|
+
}
|
|
42
|
+
return 'image/bmp';
|
|
43
|
+
}
|
|
44
|
+
_createImageMessage(buffer) {
|
|
45
|
+
return new Promise((resolve) => {
|
|
46
|
+
const commandId = buffer.getUint32();
|
|
47
|
+
const windowId = buffer.getUint32();
|
|
48
|
+
const depth = buffer.getUint32();
|
|
49
|
+
const imageType = buffer.getString(4);
|
|
50
|
+
const mimetype = this._determineMimeType(imageType);
|
|
51
|
+
const colorDataSize = buffer.getUint32();
|
|
52
|
+
const alphaDataSize = buffer.getUint32();
|
|
53
|
+
const colorData = buffer.getUint8Array(colorDataSize);
|
|
54
|
+
const alphaData = buffer.getUint8Array(alphaDataSize);
|
|
55
|
+
const colorMapPromise = this._textureFactory.createTextureFromArray(colorData, mimetype);
|
|
56
|
+
const alphaMapPromise = this._textureFactory.createTextureFromArray(alphaData, mimetype);
|
|
57
|
+
Promise.all([colorMapPromise, alphaMapPromise])
|
|
58
|
+
.then(([colorMap, alphaMap]) => {
|
|
59
|
+
resolve(new message_1.WebXImageMessage(windowId, depth, colorMap, alphaMap, commandId, buffer.bufferLength));
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
_createSubImagesMessage(buffer) {
|
|
64
|
+
return new Promise((resolve) => {
|
|
65
|
+
const commandId = buffer.getUint32();
|
|
66
|
+
const windowId = buffer.getUint32();
|
|
67
|
+
const imagePromises = new Array();
|
|
68
|
+
const numberOfSubImages = buffer.getUint32();
|
|
69
|
+
for (let i = 0; i < numberOfSubImages; i++) {
|
|
70
|
+
const x = buffer.getInt32();
|
|
71
|
+
const y = buffer.getInt32();
|
|
72
|
+
const width = buffer.getInt32();
|
|
73
|
+
const height = buffer.getInt32();
|
|
74
|
+
const depth = buffer.getUint32();
|
|
75
|
+
const imageType = buffer.getString(4);
|
|
76
|
+
const mimetype = this._determineMimeType(imageType);
|
|
77
|
+
const colorDataSize = buffer.getUint32();
|
|
78
|
+
const alphaDataSize = buffer.getUint32();
|
|
79
|
+
const colorData = buffer.getUint8Array(colorDataSize);
|
|
80
|
+
const alphaData = buffer.getUint8Array(alphaDataSize);
|
|
81
|
+
const imagePromise = new Promise((innerResolve, innerReject) => {
|
|
82
|
+
const colorMapPromise = this._textureFactory.createTextureFromArray(colorData, mimetype);
|
|
83
|
+
const alphaMapPromise = this._textureFactory.createTextureFromArray(alphaData, mimetype);
|
|
84
|
+
Promise.all([colorMapPromise, alphaMapPromise])
|
|
85
|
+
.then(([colorMap, alphaMap]) => {
|
|
86
|
+
innerResolve(new display_1.WebXSubImage({ x, y, width, height, depth, colorMap, alphaMap }));
|
|
87
|
+
})
|
|
88
|
+
.catch(innerReject);
|
|
89
|
+
});
|
|
90
|
+
imagePromises.push(imagePromise);
|
|
91
|
+
}
|
|
92
|
+
Promise.all(imagePromises).then((webXSubImages) => {
|
|
93
|
+
resolve(new message_1.WebXSubImagesMessage(windowId, webXSubImages, commandId, buffer.bufferLength));
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
_createMouseMessage(buffer) {
|
|
98
|
+
return new Promise((resolve) => {
|
|
99
|
+
const commandId = buffer.getUint32();
|
|
100
|
+
const x = buffer.getInt32();
|
|
101
|
+
const y = buffer.getInt32();
|
|
102
|
+
const cursorId = buffer.getUint32();
|
|
103
|
+
resolve(new message_1.WebXMouseMessage(x, y, cursorId, commandId));
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
_createWindowsMessage(buffer) {
|
|
107
|
+
return new Promise((resolve) => {
|
|
108
|
+
const commandId = buffer.getUint32();
|
|
109
|
+
const numberOfWindows = buffer.getUint32();
|
|
110
|
+
const windows = new Array();
|
|
111
|
+
for (let i = 0; i < numberOfWindows; i++) {
|
|
112
|
+
const windowId = buffer.getUint32();
|
|
113
|
+
const x = buffer.getInt32();
|
|
114
|
+
const y = buffer.getInt32();
|
|
115
|
+
const width = buffer.getInt32();
|
|
116
|
+
const height = buffer.getInt32();
|
|
117
|
+
windows.push(new display_1.WebXWindowProperties({ id: windowId, x: x, y: y, width: width, height: height }));
|
|
118
|
+
}
|
|
119
|
+
resolve(new message_1.WebXWindowsMessage(windows, commandId));
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
_createCursorImageMessage(buffer) {
|
|
123
|
+
return new Promise((resolve) => {
|
|
124
|
+
const commandId = buffer.getUint32();
|
|
125
|
+
const x = buffer.getInt32();
|
|
126
|
+
const y = buffer.getInt32();
|
|
127
|
+
const xHot = buffer.getInt32();
|
|
128
|
+
const yHot = buffer.getInt32();
|
|
129
|
+
const cursorId = buffer.getUint32();
|
|
130
|
+
const imageDataSize = buffer.getUint32();
|
|
131
|
+
const imageData = buffer.getUint8Array(imageDataSize);
|
|
132
|
+
this._textureFactory.createTextureFromArray(imageData, 'image/png')
|
|
133
|
+
.then(texture => {
|
|
134
|
+
resolve(new message_1.WebXCursorImageMessage(x, y, xHot, yHot, cursorId, texture, commandId));
|
|
135
|
+
})
|
|
136
|
+
.catch(() => {
|
|
137
|
+
console.error('Failed to get texture for cursor image');
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
_createScreenMessage(buffer) {
|
|
142
|
+
return new Promise((resolve) => {
|
|
143
|
+
const commandId = buffer.getUint32();
|
|
144
|
+
const screenWidth = buffer.getInt32();
|
|
145
|
+
const screenHeight = buffer.getInt32();
|
|
146
|
+
resolve(new message_1.WebXScreenMessage({ width: screenWidth, height: screenHeight }, commandId));
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
_createPollMessage() {
|
|
150
|
+
return new Promise((resolve) => {
|
|
151
|
+
resolve(new message_1.WebXPollMessage());
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.WebXMessageDecoder = WebXMessageDecoder;
|
|
156
|
+
//# sourceMappingURL=WebXMessageDecoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebXMessageDecoder.js","sourceRoot":"","sources":["../../src/transport/WebXMessageDecoder.ts"],"names":[],"mappings":";;;AAAA,wCASoB;AACpB,wCAAoF;AAGpF,MAAa,kBAAkB;IAE7B,YAAoB,eAAmC;QAAnC,oBAAe,GAAf,eAAe,CAAoB;IACvD,CAAC;IAED,MAAM,CAAC,MAAyB;QAC9B,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC;QAEjC,IAAI,aAAa,KAAK,yBAAe,CAAC,MAAM,EAAE;YAC5C,OAAO,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;SAE1C;aAAM,IAAI,aAAa,KAAK,yBAAe,CAAC,OAAO,EAAE;YACpD,OAAO,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;SAE3C;aAAM,IAAI,aAAa,KAAK,yBAAe,CAAC,KAAK,EAAE;YAClD,OAAO,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tF,CAAC,CAAC;iBACD,KAAK,CAAC,GAAG,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;YAC1D,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,oBAAoB,CAAC,MAAyB;QACpD,OAAO,IAAI,OAAO,CAAoB,CAAC,OAAO,EAAE,EAAE;YAChD,MAAM,SAAS,GAAW,MAAM,CAAC,SAAS,EAAE,CAAC;YAC7C,MAAM,WAAW,GAAW,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC9C,MAAM,YAAY,GAAW,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC/C,OAAO,CAAC,IAAI,2BAAiB,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;QAC1F,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,kBAAkB;QACxB,OAAO,IAAI,OAAO,CAAkB,CAAC,OAAO,EAAE,EAAE;YAC9C,OAAO,CAAC,IAAI,yBAAe,EAAE,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;CAEF;AAvKD,gDAuKC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./WebXInstructionBuffer"), exports);
|
|
18
|
+
__exportStar(require("./WebXMessageBuffer"), exports);
|
|
19
|
+
__exportStar(require("./WebXMessageDecoder"), exports);
|
|
20
|
+
__exportStar(require("./WebXInstructionEncoder"), exports);
|
|
21
|
+
__exportStar(require("./WebXBinarySerializer"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transport/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,sDAAoC;AACpC,uDAAqC;AACrC,2DAAyC;AACzC,yDAAuC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WebXQoSHandler } from './WebXQoSHandler';
|
|
2
|
+
import { WebXTunnel } from './WebXTunnel';
|
|
3
|
+
export declare class WebXDefaultQoSHandler extends WebXQoSHandler {
|
|
4
|
+
private _tunnel;
|
|
5
|
+
private _active;
|
|
6
|
+
private _currentQueueLength;
|
|
7
|
+
private _waiting;
|
|
8
|
+
private _currentQuality;
|
|
9
|
+
constructor(_tunnel: WebXTunnel);
|
|
10
|
+
handle(messageQueueLength: number): void;
|
|
11
|
+
setActive(isActive: boolean): void;
|
|
12
|
+
getQuality(): number;
|
|
13
|
+
setQuality(quality: number): void;
|
|
14
|
+
private _decreaseQuality;
|
|
15
|
+
private _increaseQuality;
|
|
16
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebXDefaultQoSHandler = void 0;
|
|
4
|
+
const WebXQoSHandler_1 = require("./WebXQoSHandler");
|
|
5
|
+
const instruction_1 = require("../instruction");
|
|
6
|
+
class WebXDefaultQoSHandler extends WebXQoSHandler_1.WebXQoSHandler {
|
|
7
|
+
constructor(_tunnel) {
|
|
8
|
+
super();
|
|
9
|
+
this._tunnel = _tunnel;
|
|
10
|
+
this._active = true;
|
|
11
|
+
this._currentQueueLength = 0;
|
|
12
|
+
this._waiting = false;
|
|
13
|
+
this._currentQuality = 10;
|
|
14
|
+
}
|
|
15
|
+
handle(messageQueueLength) {
|
|
16
|
+
if (this._active && !this._waiting) {
|
|
17
|
+
if (messageQueueLength > this._currentQueueLength) {
|
|
18
|
+
this._decreaseQuality();
|
|
19
|
+
this._currentQueueLength = messageQueueLength;
|
|
20
|
+
}
|
|
21
|
+
else if (messageQueueLength == 0) {
|
|
22
|
+
this._increaseQuality();
|
|
23
|
+
this._currentQueueLength = messageQueueLength;
|
|
24
|
+
}
|
|
25
|
+
this._waiting = true;
|
|
26
|
+
setTimeout(() => this._waiting = false, 500);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
setActive(isActive) {
|
|
30
|
+
this._active = isActive;
|
|
31
|
+
}
|
|
32
|
+
getQuality() {
|
|
33
|
+
return this._currentQuality;
|
|
34
|
+
}
|
|
35
|
+
setQuality(quality) {
|
|
36
|
+
this._currentQuality = quality;
|
|
37
|
+
this.dispatchEvent(new CustomEvent('quality', { detail: { quality: quality } }));
|
|
38
|
+
}
|
|
39
|
+
_decreaseQuality() {
|
|
40
|
+
if (this._currentQuality > 1) {
|
|
41
|
+
this.setQuality(this._currentQuality - 1);
|
|
42
|
+
const qualityInstruction = new instruction_1.WebXQualityInstruction(this._currentQuality);
|
|
43
|
+
this._tunnel.sendInstruction(qualityInstruction);
|
|
44
|
+
// console.log(`setting quality to ${this._currentQuality}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
_increaseQuality() {
|
|
48
|
+
if (this._currentQuality < 10) {
|
|
49
|
+
this.setQuality(this._currentQuality + 1);
|
|
50
|
+
const qualityInstruction = new instruction_1.WebXQualityInstruction(this._currentQuality);
|
|
51
|
+
this._tunnel.sendInstruction(qualityInstruction);
|
|
52
|
+
// console.log(`setting quality to ${this._currentQuality}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.WebXDefaultQoSHandler = WebXDefaultQoSHandler;
|
|
57
|
+
//# sourceMappingURL=WebXDefaultQoSHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebXDefaultQoSHandler.js","sourceRoot":"","sources":["../../src/tunnel/WebXDefaultQoSHandler.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAElD,gDAAwD;AAExD,MAAa,qBAAsB,SAAQ,+BAAc;IAMvD,YAAoB,OAAmB;QACrC,KAAK,EAAE,CAAC;QADU,YAAO,GAAP,OAAO,CAAY;QAL/B,YAAO,GAAG,IAAI,CAAC;QACf,wBAAmB,GAAG,CAAC,CAAC;QACxB,aAAQ,GAAG,KAAK,CAAC;QACjB,oBAAe,GAAG,EAAE,CAAC;IAI7B,CAAC;IAED,MAAM,CAAC,kBAA0B;QAC/B,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClC,IAAI,kBAAkB,GAAG,IAAI,CAAC,mBAAmB,EAAE;gBACjD,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACxB,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAC;aAE/C;iBAAM,IAAI,kBAAkB,IAAI,CAAC,EAAE;gBAClC,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACxB,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAC;aAC/C;YAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,GAAG,KAAK,EAAE,GAAG,CAAC,CAAC;SAC9C;IACH,CAAC;IAED,SAAS,CAAC,QAAiB;QACzB,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;IAC1B,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED,UAAU,CAAC,OAAe;QACxB,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC;QAC/B,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,EAAC,OAAO,EAAE,OAAO,EAAC,EAAC,CAAC,CAAC,CAAC;IAChF,CAAC;IAEO,gBAAgB;QACtB,IAAI,IAAI,CAAC,eAAe,GAAG,CAAC,EAAE;YAC5B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC;YAC1C,MAAM,kBAAkB,GAAG,IAAI,oCAAsB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAC5E,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;YACjD,6DAA6D;SAC9D;IACH,CAAC;IAEO,gBAAgB;QACtB,IAAI,IAAI,CAAC,eAAe,GAAG,EAAE,EAAE;YAC7B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC;YAC1C,MAAM,kBAAkB,GAAG,IAAI,oCAAsB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAC5E,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;YACjD,6DAA6D;SAC9D;IACH,CAAC;CAEF;AAzDD,sDAyDC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebXQoSHandler.js","sourceRoot":"","sources":["../../src/tunnel/WebXQoSHandler.ts"],"names":[],"mappings":";;;AAAA,MAAsB,cAAe,SAAQ,WAAW;CAKvD;AALD,wCAKC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="socket.io-client" />
|
|
2
|
+
import { WebXTunnel } from './WebXTunnel';
|
|
3
|
+
import { WebXBinarySerializer } from '../transport';
|
|
4
|
+
import Socket = SocketIOClient.Socket;
|
|
5
|
+
export declare class WebXSocketIOTunnel extends WebXTunnel {
|
|
6
|
+
private readonly _url;
|
|
7
|
+
private readonly _eventChannel;
|
|
8
|
+
private readonly _connectionOptions;
|
|
9
|
+
private _socket;
|
|
10
|
+
constructor(url: string, options: any, eventChannel: string);
|
|
11
|
+
getSocket(): Socket;
|
|
12
|
+
send(data: ArrayBuffer): void;
|
|
13
|
+
connect(data: any, serializer: WebXBinarySerializer): Promise<Event>;
|
|
14
|
+
disconnect(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebXSocketIOTunnel = void 0;
|
|
4
|
+
const WebXTunnel_1 = require("./WebXTunnel");
|
|
5
|
+
class WebXSocketIOTunnel extends WebXTunnel_1.WebXTunnel {
|
|
6
|
+
constructor(url, options = {}, eventChannel) {
|
|
7
|
+
super();
|
|
8
|
+
this._connectionOptions = options;
|
|
9
|
+
this._url = url;
|
|
10
|
+
this._eventChannel = eventChannel;
|
|
11
|
+
this._serializer = null;
|
|
12
|
+
}
|
|
13
|
+
getSocket() {
|
|
14
|
+
return this._socket;
|
|
15
|
+
}
|
|
16
|
+
send(data) {
|
|
17
|
+
this._socket.emit(this._eventChannel, data);
|
|
18
|
+
this.handleSentBytes(data);
|
|
19
|
+
}
|
|
20
|
+
connect(data, serializer) {
|
|
21
|
+
const options = Object.assign({}, this._connectionOptions);
|
|
22
|
+
const parameters = new URLSearchParams(data);
|
|
23
|
+
options.query = parameters.toString();
|
|
24
|
+
this._serializer = serializer;
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
this._socket = io(this._url, options);
|
|
27
|
+
this._socket.on('connect', () => resolve(null));
|
|
28
|
+
this._socket.on('disconnect', this.handleClose.bind(this));
|
|
29
|
+
this._socket.on('connect_error', (event) => reject(event));
|
|
30
|
+
this._socket.on(this._eventChannel, (message) => this.onMessage(message));
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
disconnect() {
|
|
34
|
+
if (this._socket) {
|
|
35
|
+
this._socket.disconnect();
|
|
36
|
+
this._socket = null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.WebXSocketIOTunnel = WebXSocketIOTunnel;
|
|
41
|
+
//# sourceMappingURL=WebXSocketIOTunnel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebXSocketIOTunnel.js","sourceRoot":"","sources":["../../src/tunnel/WebXSocketIOTunnel.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAK1C,MAAa,kBAAmB,SAAQ,uBAAU;IAOhD,YAAY,GAAW,EAAE,UAAe,EAAE,EAAE,YAAoB;QAC9D,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAI,CAAC,IAAiB;QACpB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,CAAC,IAAS,EAAE,UAAgC;QACjD,MAAM,OAAO,qBAAO,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC7C,MAAM,UAAU,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,CAAC,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;QAEtC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,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