justrun-ws 0.1.2 → 0.2.0
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/lib/WsClient.js +198 -0
- package/lib/bundle.min.js +1 -1
- package/lib/common/AdjustableTimer.js +42 -0
- package/lib/common/DataWrapper.js +16 -16
- package/lib/common/List.js +27 -27
- package/lib/common/utils.js +19 -19
- package/lib/common/varUintOps.js +51 -51
- package/lib/handler/SimpleHandler.js +49 -55
- package/lib/handler/common.js +6 -9
- package/lib/index.d.ts +48 -135
- package/lib/index.js +2 -5
- package/lib/net/BrowserWsNet.js +48 -45
- package/lib/net/LazyConn.js +41 -30
- package/lib/net/PackageWrapper.js +16 -16
- package/lib/net/TimeoutMonitor.js +40 -40
- package/lib/net/TypedPkgHub.js +167 -164
- package/lib/net/hubPkgSerializer.js +4 -4
- package/package.json +1 -1
|
@@ -39,33 +39,33 @@ class EventWrapper extends PkgWrapper {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
class RequestWrapper extends PkgWrapper {
|
|
42
|
-
constructor(
|
|
43
|
-
super(
|
|
42
|
+
constructor(a, needParse) {
|
|
43
|
+
super(a, needParse);
|
|
44
44
|
}
|
|
45
45
|
isRequest() {
|
|
46
46
|
return true;
|
|
47
47
|
}
|
|
48
48
|
get resp() {
|
|
49
|
-
if (!this.
|
|
50
|
-
this.
|
|
49
|
+
if (!this.z) {
|
|
50
|
+
this.z = this.decodeResponse(this.$);
|
|
51
51
|
}
|
|
52
|
-
return this.
|
|
52
|
+
return this.z;
|
|
53
53
|
}
|
|
54
|
-
set resp(
|
|
55
|
-
this.
|
|
56
|
-
this
|
|
54
|
+
set resp(b) {
|
|
55
|
+
this.z = b;
|
|
56
|
+
this.$ = undefined;
|
|
57
57
|
}
|
|
58
58
|
get respBuff() {
|
|
59
|
-
if (!this
|
|
60
|
-
this
|
|
59
|
+
if (!this.$) {
|
|
60
|
+
this.$ = this.encodeResponse(this.z);
|
|
61
61
|
}
|
|
62
|
-
return this
|
|
62
|
+
return this.$;
|
|
63
63
|
}
|
|
64
|
-
set respBuff(
|
|
65
|
-
this.
|
|
66
|
-
this
|
|
64
|
+
set respBuff(b) {
|
|
65
|
+
this.z = undefined;
|
|
66
|
+
this.$ = b;
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
z;
|
|
69
|
+
$;
|
|
70
70
|
}
|
|
71
71
|
//# sourceMappingURL=PackageWrapper.js.map
|
|
@@ -1,70 +1,70 @@
|
|
|
1
1
|
import { ListNode, c } from '../common/List';
|
|
2
|
-
import {
|
|
2
|
+
import { l } from '../common/utils';
|
|
3
3
|
export class MonitorConn extends ListNode {
|
|
4
4
|
}
|
|
5
5
|
export class TimeoutMonitor {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
8
|
-
this.
|
|
9
|
-
this.
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
if (
|
|
14
|
-
this.insert =
|
|
15
|
-
this.update =
|
|
16
|
-
this.remove =
|
|
6
|
+
constructor(f, h, g) {
|
|
7
|
+
this.R = f;
|
|
8
|
+
this.J = h;
|
|
9
|
+
this.D = g;
|
|
10
|
+
this.o = 0;
|
|
11
|
+
this.E = 0;
|
|
12
|
+
this.t = [];
|
|
13
|
+
if (f === 0) {
|
|
14
|
+
this.insert = l;
|
|
15
|
+
this.update = l;
|
|
16
|
+
this.remove = l;
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
for (let
|
|
20
|
-
this.
|
|
19
|
+
for (let a = 0; a < g; a++) {
|
|
20
|
+
this.t.push(new c());
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
insert(conn) {
|
|
24
|
-
if (!this.
|
|
25
|
-
this.
|
|
24
|
+
if (!this.E) {
|
|
25
|
+
this.S = setInterval(this.a2, this.R);
|
|
26
26
|
}
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
27
|
+
this.E++;
|
|
28
|
+
this.t[this.o].Q(conn);
|
|
29
29
|
}
|
|
30
30
|
update(conn) {
|
|
31
31
|
conn.remove();
|
|
32
|
-
this.
|
|
32
|
+
this.t[this.o].Q(conn);
|
|
33
33
|
}
|
|
34
34
|
remove(conn) {
|
|
35
35
|
conn.remove();
|
|
36
|
-
this.
|
|
37
|
-
if (!this.
|
|
38
|
-
clearInterval(this.
|
|
36
|
+
this.E--;
|
|
37
|
+
if (!this.E) {
|
|
38
|
+
clearInterval(this.S);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
const {
|
|
43
|
-
this.
|
|
44
|
-
if (this.
|
|
45
|
-
this.
|
|
41
|
+
a2 = () => {
|
|
42
|
+
const { J, D, t } = this;
|
|
43
|
+
this.o++;
|
|
44
|
+
if (this.o === D) {
|
|
45
|
+
this.o = 0;
|
|
46
46
|
}
|
|
47
|
-
if (
|
|
48
|
-
let d = this.
|
|
49
|
-
if (d >=
|
|
50
|
-
d -=
|
|
47
|
+
if (J) {
|
|
48
|
+
let d = this.o + J;
|
|
49
|
+
if (d >= D) {
|
|
50
|
+
d -= D;
|
|
51
51
|
}
|
|
52
|
-
const
|
|
53
|
-
for (let node =
|
|
52
|
+
const b = t[d];
|
|
53
|
+
for (let node = b.e; !b.P(node); node = node.getNext()) {
|
|
54
54
|
node.keepAlive();
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
const
|
|
58
|
-
for (let node =
|
|
57
|
+
const b = t[this.o];
|
|
58
|
+
for (let node = b.e; !b.P(node); node = node.getNext()) {
|
|
59
59
|
node.timeout();
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
+
R;
|
|
63
|
+
J;
|
|
62
64
|
D;
|
|
63
|
-
y;
|
|
64
|
-
w;
|
|
65
|
-
j;
|
|
66
|
-
x;
|
|
67
|
-
E;
|
|
68
65
|
o;
|
|
66
|
+
E;
|
|
67
|
+
S;
|
|
68
|
+
t;
|
|
69
69
|
}
|
|
70
70
|
//# sourceMappingURL=TimeoutMonitor.js.map
|
package/lib/net/TypedPkgHub.js
CHANGED
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { y, l } from '../common/utils';
|
|
2
2
|
import { MonitorConn } from './TimeoutMonitor';
|
|
3
|
-
export class
|
|
4
|
-
constructor(
|
|
5
|
-
const { responsePkgType, timeoutMonitor, makePkgBuff, parsePkgBuff } =
|
|
3
|
+
export class t {
|
|
4
|
+
constructor(C, w) {
|
|
5
|
+
const { responsePkgType, timeoutMonitor, makePkgBuff, parsePkgBuff } = w;
|
|
6
6
|
this.responsePkgType = responsePkgType;
|
|
7
7
|
this.context = undefined;
|
|
8
|
-
this.
|
|
9
|
-
this.
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
this
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
8
|
+
this.F = undefined;
|
|
9
|
+
this.G = undefined;
|
|
10
|
+
this.u = 0;
|
|
11
|
+
this.v = new Map();
|
|
12
|
+
this.e = new Map();
|
|
13
|
+
this.L = new Map();
|
|
14
|
+
this.T = makePkgBuff;
|
|
15
|
+
this.U = parsePkgBuff;
|
|
16
|
+
this.A = C;
|
|
17
|
+
this.K = timeoutMonitor;
|
|
18
|
+
const Q = this;
|
|
19
|
+
Q.$ = this.a3;
|
|
20
|
+
const s = [];
|
|
21
|
+
this.T(responsePkgType, 0x200000, s);
|
|
22
|
+
this.V = {
|
|
23
23
|
makePkgBuff: makePkgBuff,
|
|
24
24
|
responsePkgType: responsePkgType,
|
|
25
|
-
|
|
25
|
+
s: y(s),
|
|
26
26
|
};
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
27
|
+
this.e.set(responsePkgType, Q);
|
|
28
|
+
this.A.N((b, q) => {
|
|
29
29
|
do {
|
|
30
|
-
this.
|
|
31
|
-
} while (this.
|
|
32
|
-
const conn = new
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
35
|
-
const
|
|
30
|
+
this.u++;
|
|
31
|
+
} while (this.v.has(this.u & 0x1fffff));
|
|
32
|
+
const conn = new x(this.V, b, this.u & 0x1fffff);
|
|
33
|
+
this.v.set(conn.id, conn);
|
|
34
|
+
this.K?.insert(conn);
|
|
35
|
+
const g = {
|
|
36
36
|
conn,
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
D: (buff) => this.a4(conn, buff),
|
|
38
|
+
n: (err) => this.a5(conn, err),
|
|
39
39
|
};
|
|
40
|
-
this.
|
|
41
|
-
return
|
|
40
|
+
this.F?.(this, conn, !!q);
|
|
41
|
+
return g;
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
responsePkgType;
|
|
45
45
|
context;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return this.
|
|
46
|
+
F;
|
|
47
|
+
G;
|
|
48
|
+
o() {
|
|
49
|
+
return this.A.o();
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
return this.
|
|
51
|
+
Z(z) {
|
|
52
|
+
return this.v.get(z);
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
return this.
|
|
54
|
+
c(d) {
|
|
55
|
+
return this.A.c(d);
|
|
56
56
|
}
|
|
57
|
-
async
|
|
57
|
+
async a0() {
|
|
58
58
|
do {
|
|
59
|
-
this.
|
|
60
|
-
} while (this.
|
|
61
|
-
const conn = new
|
|
62
|
-
this.
|
|
59
|
+
this.u++;
|
|
60
|
+
} while (this.v.has(this.u & 0x1fffff));
|
|
61
|
+
const conn = new a6(this.u & 0x1fffff, this);
|
|
62
|
+
this.v.set(conn.id, conn);
|
|
63
63
|
return conn;
|
|
64
64
|
}
|
|
65
|
-
async
|
|
66
|
-
return this.
|
|
65
|
+
async a1(d) {
|
|
66
|
+
return this.A.O(d);
|
|
67
67
|
}
|
|
68
|
-
async
|
|
69
|
-
return this.
|
|
68
|
+
async a2() {
|
|
69
|
+
return this.A.P();
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
a7(conn, message) {
|
|
72
72
|
const pkgType = message.constructor.pkgType;
|
|
73
|
-
const handler = this.
|
|
73
|
+
const handler = this.e.get(pkgType);
|
|
74
74
|
if (handler) {
|
|
75
|
-
return handler?.
|
|
75
|
+
return handler?.r(conn, message);
|
|
76
76
|
}
|
|
77
77
|
throw new Error('Invalid package');
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
a8(conn, request) {
|
|
80
80
|
const pkgType = request.constructor.pkgType;
|
|
81
|
-
const handler = this.
|
|
81
|
+
const handler = this.e.get(pkgType);
|
|
82
82
|
if (handler) {
|
|
83
|
-
return handler?.
|
|
83
|
+
return handler?.r(conn, request);
|
|
84
84
|
}
|
|
85
85
|
throw new Error('Invalid package');
|
|
86
86
|
}
|
|
87
87
|
registerError(pkgType, wrapperCtor) {
|
|
88
88
|
wrapperCtor.registerPkgType(pkgType);
|
|
89
|
-
this
|
|
90
|
-
const
|
|
91
|
-
this.
|
|
89
|
+
this.L.set(pkgType, wrapperCtor);
|
|
90
|
+
const a9 = this.e.get(this.responsePkgType);
|
|
91
|
+
this.e.set(pkgType, a9);
|
|
92
92
|
}
|
|
93
93
|
registerMessage(pkgType, wrapperCtor) {
|
|
94
94
|
wrapperCtor.registerPkgType(pkgType);
|
|
@@ -99,197 +99,200 @@ export class TypedPkgHub {
|
|
|
99
99
|
handleMessageWith(handler) {
|
|
100
100
|
const pkgType = handler.pkgType;
|
|
101
101
|
if (typeof pkgType !== typeof this.responsePkgType) {
|
|
102
|
-
throw new Error(`Wrapper ${handler.
|
|
102
|
+
throw new Error(`Wrapper ${handler.m} has an incompatible pkgType ${typeof pkgType}`);
|
|
103
103
|
}
|
|
104
|
-
if (this.
|
|
105
|
-
throw new Error(`Wrapper ${handler.
|
|
104
|
+
if (this.e.has(pkgType)) {
|
|
105
|
+
throw new Error(`Wrapper ${handler.m} is already handled by another handler`);
|
|
106
106
|
}
|
|
107
|
-
this.
|
|
107
|
+
this.e.set(pkgType, handler);
|
|
108
108
|
return handler;
|
|
109
109
|
}
|
|
110
110
|
handleRequestWith(handler) {
|
|
111
111
|
const pkgType = handler.pkgType;
|
|
112
112
|
if (typeof pkgType !== typeof this.responsePkgType) {
|
|
113
|
-
throw new Error(`Wrapper ${handler.
|
|
113
|
+
throw new Error(`Wrapper ${handler.m} has an incompatible pkgType ${typeof pkgType}`);
|
|
114
114
|
}
|
|
115
|
-
if (this.
|
|
116
|
-
throw new Error(`Wrapper ${handler.
|
|
115
|
+
if (this.e.has(pkgType)) {
|
|
116
|
+
throw new Error(`Wrapper ${handler.m} is already handled by another handler`);
|
|
117
117
|
}
|
|
118
|
-
this.
|
|
118
|
+
this.e.set(pkgType, handler);
|
|
119
119
|
return handler;
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
ak(handler) {
|
|
122
122
|
const pkgType = handler.pkgType;
|
|
123
|
-
const
|
|
124
|
-
if (
|
|
125
|
-
this.
|
|
123
|
+
const aa = this.e.get(pkgType);
|
|
124
|
+
if (aa === handler) {
|
|
125
|
+
this.e.delete(pkgType);
|
|
126
126
|
return true;
|
|
127
127
|
}
|
|
128
128
|
return false;
|
|
129
129
|
}
|
|
130
|
-
|
|
131
|
-
this.
|
|
132
|
-
const
|
|
133
|
-
const handler = this.
|
|
130
|
+
a4(conn, buff) {
|
|
131
|
+
this.K?.update(conn);
|
|
132
|
+
const a = this.U(buff);
|
|
133
|
+
const handler = this.e.get(a.pkgType);
|
|
134
134
|
if (handler) {
|
|
135
|
-
handler
|
|
135
|
+
handler.$(conn, a);
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
138
|
conn.close(new Error('Invalid package'));
|
|
139
139
|
}
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
this.
|
|
143
|
-
this.
|
|
144
|
-
conn.
|
|
145
|
-
this.
|
|
140
|
+
a5(conn, err) {
|
|
141
|
+
const z = conn.id;
|
|
142
|
+
this.v.delete(z);
|
|
143
|
+
this.K?.remove(conn);
|
|
144
|
+
conn.n(err);
|
|
145
|
+
this.G?.(this, conn, conn.b.J(), err);
|
|
146
146
|
}
|
|
147
|
-
|
|
148
|
-
const { buff, pkgType, requestId, bodyOffset } =
|
|
147
|
+
a3(conn, a) {
|
|
148
|
+
const { buff, pkgType, requestId, bodyOffset } = a;
|
|
149
149
|
if (pkgType === this.responsePkgType) {
|
|
150
|
-
const
|
|
151
|
-
conn.
|
|
150
|
+
const h = buff.subarray(bodyOffset);
|
|
151
|
+
conn.W(requestId, h);
|
|
152
152
|
}
|
|
153
153
|
else {
|
|
154
|
-
const
|
|
155
|
-
if (
|
|
156
|
-
const
|
|
157
|
-
const
|
|
158
|
-
conn.
|
|
154
|
+
const S = this.L.get(pkgType);
|
|
155
|
+
if (S) {
|
|
156
|
+
const h = buff.subarray(bodyOffset);
|
|
157
|
+
const ab = new S(h, true);
|
|
158
|
+
conn.ac(requestId, ab);
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
|
|
163
|
-
p;
|
|
164
|
-
F;
|
|
165
|
-
G;
|
|
162
|
+
V;
|
|
166
163
|
u;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
164
|
+
T;
|
|
165
|
+
U;
|
|
166
|
+
A;
|
|
167
|
+
v;
|
|
168
|
+
e;
|
|
169
|
+
L;
|
|
170
|
+
K;
|
|
171
171
|
}
|
|
172
|
-
class
|
|
173
|
-
constructor(
|
|
172
|
+
class x extends MonitorConn {
|
|
173
|
+
constructor(w, b, id) {
|
|
174
174
|
super();
|
|
175
175
|
this.context = undefined;
|
|
176
176
|
this.id = id;
|
|
177
|
-
this.
|
|
178
|
-
this.
|
|
179
|
-
this.
|
|
180
|
-
this.
|
|
177
|
+
this.b = b;
|
|
178
|
+
this.B = w;
|
|
179
|
+
this.j = undefined;
|
|
180
|
+
this.X = 0;
|
|
181
181
|
}
|
|
182
182
|
context;
|
|
183
183
|
id;
|
|
184
|
-
|
|
184
|
+
b;
|
|
185
185
|
get localAddress() {
|
|
186
|
-
return this.
|
|
186
|
+
return this.b.localAddress;
|
|
187
187
|
}
|
|
188
188
|
get localPort() {
|
|
189
|
-
return this.
|
|
189
|
+
return this.b.localPort;
|
|
190
190
|
}
|
|
191
191
|
get remoteAddress() {
|
|
192
|
-
return this.
|
|
192
|
+
return this.b.remoteAddress;
|
|
193
193
|
}
|
|
194
194
|
get remoteFamily() {
|
|
195
|
-
return this.
|
|
195
|
+
return this.b.remoteFamily;
|
|
196
196
|
}
|
|
197
197
|
get remotePort() {
|
|
198
|
-
return this.
|
|
198
|
+
return this.b.remotePort;
|
|
199
199
|
}
|
|
200
200
|
sendMessage(message) {
|
|
201
201
|
const pkgType = message.constructor.pkgType;
|
|
202
202
|
const encoded = [message.buff];
|
|
203
|
-
this.
|
|
204
|
-
return this.
|
|
203
|
+
this.B.makePkgBuff(pkgType, 0, encoded);
|
|
204
|
+
return this.b.p(encoded);
|
|
205
205
|
}
|
|
206
206
|
sendRequest(request) {
|
|
207
|
-
this.
|
|
208
|
-
this.sendRequest = this.
|
|
209
|
-
this.
|
|
210
|
-
this.
|
|
211
|
-
return this.
|
|
207
|
+
this.j = new Map();
|
|
208
|
+
this.sendRequest = this.Y;
|
|
209
|
+
this.W = this.ad;
|
|
210
|
+
this.n = this.ae;
|
|
211
|
+
return this.Y(request);
|
|
212
212
|
}
|
|
213
213
|
sendErrorResponse(error, requestId) {
|
|
214
214
|
const pkgType = error.constructor.pkgType;
|
|
215
215
|
const encoded = [error.buff];
|
|
216
|
-
this.
|
|
217
|
-
return this.
|
|
216
|
+
this.B.makePkgBuff(pkgType, requestId, encoded);
|
|
217
|
+
return this.b.p(encoded);
|
|
218
218
|
}
|
|
219
219
|
sendResponse(request, requestId) {
|
|
220
220
|
const encoded = [request.respBuff];
|
|
221
|
-
const { makePkgBuff, responsePkgType } = this.
|
|
221
|
+
const { makePkgBuff, responsePkgType } = this.B;
|
|
222
222
|
makePkgBuff(responsePkgType, requestId, encoded);
|
|
223
|
-
return this.
|
|
223
|
+
return this.b.p(encoded);
|
|
224
224
|
}
|
|
225
225
|
async close(err) {
|
|
226
|
-
await this.
|
|
226
|
+
await this.b.close(err);
|
|
227
227
|
}
|
|
228
|
-
|
|
228
|
+
W(requestId, al) {
|
|
229
229
|
if (requestId === 0x200000 && this.context === undefined) {
|
|
230
230
|
this.close(new Error('Authenticating timeout'));
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
-
|
|
234
|
-
const
|
|
235
|
-
if (
|
|
236
|
-
this.
|
|
237
|
-
return
|
|
233
|
+
ac(requestId, error) {
|
|
234
|
+
const k = this.j.get(requestId);
|
|
235
|
+
if (k) {
|
|
236
|
+
this.j.delete(requestId);
|
|
237
|
+
return k.i(error);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
keepAlive() {
|
|
241
|
-
this.
|
|
241
|
+
this.b.I(this.B.s).catch(l);
|
|
242
242
|
}
|
|
243
243
|
timeout() {
|
|
244
244
|
this.close(new Error('Connection timeout'));
|
|
245
245
|
}
|
|
246
|
-
|
|
246
|
+
n(af) {
|
|
247
247
|
}
|
|
248
|
-
async
|
|
249
|
-
const requestId = (this.
|
|
250
|
-
const B = new Promise((f, g) => {
|
|
251
|
-
const C = { f, g };
|
|
252
|
-
this.h.set(requestId, C);
|
|
253
|
-
});
|
|
248
|
+
async Y(request) {
|
|
249
|
+
const requestId = (this.X++) & 0x1fffff;
|
|
254
250
|
const pkgType = request.constructor.pkgType;
|
|
255
251
|
const encoded = [request.buff];
|
|
256
|
-
this.
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
252
|
+
this.B.makePkgBuff(pkgType, requestId, encoded);
|
|
253
|
+
const ag = new Promise((f, i) => {
|
|
254
|
+
const ah = { f, i };
|
|
255
|
+
this.j.set(requestId, ah);
|
|
256
|
+
this.b.p(encoded).catch((err) => {
|
|
257
|
+
this.j.delete(requestId);
|
|
258
|
+
i(err);
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
request.respBuff = await ag;
|
|
262
|
+
}
|
|
263
|
+
ad(requestId, h) {
|
|
264
|
+
const k = this.j.get(requestId);
|
|
265
|
+
if (k) {
|
|
266
|
+
this.j.delete(requestId);
|
|
267
|
+
k.f(h);
|
|
265
268
|
return;
|
|
266
269
|
}
|
|
267
270
|
if (requestId === 0x200000 && this.context === undefined) {
|
|
268
271
|
this.close(new Error('Authenticating timeout'));
|
|
269
272
|
}
|
|
270
273
|
}
|
|
271
|
-
|
|
272
|
-
const
|
|
273
|
-
if (
|
|
274
|
+
ae(err) {
|
|
275
|
+
const H = this.j;
|
|
276
|
+
if (H.size > 0) {
|
|
274
277
|
if (!err) {
|
|
275
278
|
err = new Error('Connection is closed');
|
|
276
279
|
}
|
|
277
|
-
for (const [requestId,
|
|
278
|
-
|
|
279
|
-
|
|
280
|
+
for (const [requestId, k] of H) {
|
|
281
|
+
H.delete(requestId);
|
|
282
|
+
k.i(err);
|
|
280
283
|
}
|
|
281
284
|
}
|
|
282
|
-
this.
|
|
285
|
+
this.j = undefined;
|
|
283
286
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
+
B;
|
|
288
|
+
j;
|
|
289
|
+
X;
|
|
287
290
|
}
|
|
288
|
-
class
|
|
289
|
-
constructor(id,
|
|
291
|
+
class a6 {
|
|
292
|
+
constructor(id, ai) {
|
|
290
293
|
this.context = undefined;
|
|
291
294
|
this.id = id;
|
|
292
|
-
this.
|
|
295
|
+
this.M = ai;
|
|
293
296
|
}
|
|
294
297
|
context;
|
|
295
298
|
id;
|
|
@@ -301,19 +304,19 @@ class t {
|
|
|
301
304
|
return 'Local';
|
|
302
305
|
}
|
|
303
306
|
async sendMessage(message) {
|
|
304
|
-
return this.
|
|
307
|
+
return this.M.a7(this, message);
|
|
305
308
|
}
|
|
306
309
|
async sendRequest(request) {
|
|
307
|
-
return this.
|
|
310
|
+
return this.M.a8(this, request);
|
|
308
311
|
}
|
|
309
|
-
sendErrorResponse(
|
|
312
|
+
sendErrorResponse(am, aj) {
|
|
310
313
|
throw null;
|
|
311
314
|
}
|
|
312
|
-
sendResponse(
|
|
315
|
+
sendResponse(_request, aj) {
|
|
313
316
|
throw null;
|
|
314
317
|
}
|
|
315
|
-
async close(
|
|
318
|
+
async close(af) {
|
|
316
319
|
}
|
|
317
|
-
|
|
320
|
+
M;
|
|
318
321
|
}
|
|
319
322
|
//# sourceMappingURL=TypedPkgHub.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { j, l, m } from '../common/varUintOps';
|
|
2
|
-
export const
|
|
2
|
+
export const o = (pkgType, requestId, encoded) => {
|
|
3
3
|
const i = [requestId, pkgType];
|
|
4
4
|
const b = j(i);
|
|
5
5
|
const a = new Uint8Array(b);
|
|
6
6
|
m(i, a);
|
|
7
7
|
encoded.push(a);
|
|
8
8
|
};
|
|
9
|
-
export const
|
|
9
|
+
export const p = (buff) => {
|
|
10
10
|
const { h: [requestId, pkgType], k: bodyOffset } = l(2, buff);
|
|
11
|
-
const
|
|
12
|
-
return
|
|
11
|
+
const result = { buff, pkgType, requestId, bodyOffset };
|
|
12
|
+
return result;
|
|
13
13
|
};
|
|
14
14
|
//# sourceMappingURL=hubPkgSerializer.js.map
|