@netifyjs/protocol 1.0.0-alpha.3 → 1.0.0-beta.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/package.json +2 -2
- package/src/codec/index.ts +51 -221
- package/src/dispatch/dispatcher/index.ts +89 -47
- package/src/dispatch/session/index.ts +6 -24
- package/src/index.ts +2 -4
- package/src/photon/balancing/codec/index.ts +27 -53
- package/src/photon/balancing/format/authenticate/request/index.ts +52 -6
- package/src/photon/balancing/format/friends/request/index.ts +21 -5
- package/src/photon/balancing/format/game/create/request/index.ts +45 -8
- package/src/photon/balancing/format/game/debug/request/index.ts +19 -4
- package/src/photon/balancing/format/game/join/request/index.ts +65 -13
- package/src/photon/balancing/format/game/list/request/index.ts +29 -3
- package/src/photon/balancing/format/game/random/request/index.ts +58 -10
- package/src/photon/balancing/format/groups/request/index.ts +19 -3
- package/src/photon/balancing/format/index.ts +7 -0
- package/src/photon/balancing/format/leave/request/index.ts +19 -3
- package/src/photon/balancing/format/lobby/join/request/index.ts +23 -3
- package/src/photon/balancing/format/lobby/stats/request/index.ts +19 -3
- package/src/photon/balancing/format/once/request/index.ts +31 -8
- package/src/photon/balancing/format/properties/get/request/index.ts +31 -4
- package/src/photon/balancing/format/properties/set/request/index.ts +36 -7
- package/src/photon/balancing/format/raise/request/index.ts +76 -10
- package/src/photon/balancing/format/reader/index.ts +75 -6
- package/src/photon/balancing/format/regions/request/index.ts +16 -1
- package/src/photon/balancing/format/rpc/request/index.ts +26 -3
- package/src/photon/balancing/format/settings/request/index.ts +15 -2
- package/src/photon/balancing/format/shared/credentials/index.ts +77 -33
- package/src/photon/balancing/format/shared/lobby/index.ts +41 -5
- package/src/photon/balancing/format/shared/options/index.ts +56 -24
- package/src/photon/balancing/format/table/index.ts +399 -0
- package/src/photon/balancing/index.ts +11 -1
- package/src/photon/balancing/travel/index.ts +15 -12
- package/src/photon/client/connection/index.ts +6 -6
- package/src/photon/cluster/back/index.ts +32 -45
- package/src/photon/cluster/dresser/index.ts +7 -8
- package/src/photon/cluster/front/index.ts +25 -49
- package/src/photon/cluster/grid/index.ts +1 -1
- package/src/photon/cluster/mover/index.ts +12 -12
- package/src/photon/cluster/press/index.ts +2 -18
- package/src/photon/cluster/route/game/index.ts +9 -11
- package/src/photon/cluster/route/master/index.ts +15 -34
- package/src/photon/cluster/route/name/index.ts +4 -21
- package/src/photon/cluster/seat/game/index.ts +6 -26
- package/src/photon/cluster/seat/master/index.ts +1 -1
- package/src/photon/cluster/sessions/index.ts +5 -6
- package/src/photon/cluster/spread/index.ts +8 -147
- package/src/photon/enet/client/index.ts +1 -8
- package/src/photon/enet/gateway/index.ts +5 -15
- package/src/photon/enet/index.ts +1 -1
- package/src/photon/enet/link/index.ts +34 -15
- package/src/photon/enet/outbound/index.ts +279 -0
- package/src/photon/enet/peer/index.ts +59 -0
- package/src/photon/enet/transport/index.ts +8 -24
- package/src/photon/game/admission/index.ts +353 -0
- package/src/photon/game/bag/index.ts +13 -0
- package/src/photon/game/broadcast/index.ts +79 -0
- package/src/photon/game/editor/index.ts +446 -0
- package/src/photon/game/gate/index.ts +9 -8
- package/src/photon/game/handler/index.ts +30 -3
- package/src/photon/game/history/index.ts +234 -0
- package/src/photon/game/hooked/index.ts +16 -15
- package/src/photon/game/index.ts +12 -1
- package/src/photon/game/lifecycle/index.ts +193 -0
- package/src/photon/game/peer/index.ts +1 -10
- package/src/photon/game/properties/index.ts +342 -0
- package/src/photon/game/room/index.ts +435 -1793
- package/src/photon/game/rooms/index.ts +2 -1
- package/src/photon/game/seats/index.ts +237 -0
- package/src/photon/game/server/index.ts +12 -2
- package/src/photon/game/services/index.ts +41 -0
- package/src/photon/game/settings/index.ts +22 -0
- package/src/photon/game/snapshot/index.ts +133 -0
- package/src/photon/game/throttle/index.ts +60 -0
- package/src/photon/game/touch/index.ts +2 -5
- package/src/photon/game/venue/index.ts +31 -0
- package/src/photon/master/application/index.ts +7 -0
- package/src/photon/master/gate/index.ts +12 -8
- package/src/photon/master/handler/index.ts +36 -748
- package/src/photon/master/index.ts +5 -0
- package/src/photon/master/list/sql/index.ts +37 -3
- package/src/photon/master/listing/index.ts +133 -0
- package/src/photon/master/lobby/index.ts +9 -0
- package/src/photon/master/login/index.ts +424 -0
- package/src/photon/master/matchmaking/index.ts +282 -0
- package/src/photon/master/query/index.ts +45 -0
- package/src/photon/master/redirect/index.ts +8 -7
- package/src/photon/master/services/index.ts +35 -0
- package/src/photon/master/settings/index.ts +44 -0
- package/src/photon/master/sql/cost/index.ts +263 -0
- package/src/photon/master/sql/index.ts +1 -0
- package/src/photon/message/client/index.ts +14 -11
- package/src/photon/message/handler/index.ts +22 -64
- package/src/photon/message/pipeline/index.ts +12 -12
- package/src/photon/message/server/index.ts +87 -43
- package/src/photon/message/watch/index.ts +14 -37
- package/src/photon/server/deferral/index.ts +57 -0
- package/src/photon/server/host/index.ts +32 -10
- package/src/photon/server/index.ts +1 -0
- package/src/photon/tcp/client/index.ts +1 -1
- package/src/photon/tcp/codec/index.ts +13 -42
- package/src/photon/tcp/server/index.ts +4 -4
- package/src/photon/websocket/bridge/index.ts +16 -20
- package/src/photon/websocket/message/index.ts +27 -39
- package/src/photon/websocket/path/index.ts +2 -5
- package/src/scale/fanout/index.ts +6 -6
- package/src/scale/index.ts +2 -4
- package/src/scale/outbound/index.ts +192 -0
- package/src/scale/relay/index.ts +20 -31
- package/src/scale/sink/index.ts +6 -11
- package/src/scale/transport/index.ts +27 -44
- package/src/scale/tunnel/index.ts +37 -91
- package/src/smartfox/common/bluebox/gateway/index.ts +401 -0
- package/src/smartfox/common/bluebox/index.ts +4 -0
- package/src/smartfox/{x2 → common}/bluebox/transport/index.ts +36 -23
- package/src/smartfox/common/index.ts +5 -0
- package/src/smartfox/common/strikes/index.ts +74 -0
- package/src/smartfox/pro/bluebox/index.ts +176 -4
- package/src/smartfox/pro/codec/index.ts +8 -7
- package/src/smartfox/pro/escalation/index.ts +28 -20
- package/src/smartfox/pro/flood/index.ts +2 -2
- package/src/smartfox/pro/format/extension/raw/index.ts +12 -2
- package/src/smartfox/pro/handler/chat/index.ts +11 -8
- package/src/smartfox/pro/handler/login/index.ts +2 -25
- package/src/smartfox/pro/handler/shared/index.ts +4 -3
- package/src/smartfox/pro/index.ts +11 -5
- package/src/smartfox/pro/login/gate/index.ts +166 -0
- package/src/smartfox/pro/login/index.ts +1 -0
- package/src/smartfox/pro/moderation/index.ts +220 -0
- package/src/smartfox/pro/options/index.ts +5 -5
- package/src/smartfox/pro/protocol/index.ts +62 -8
- package/src/smartfox/pro/web/index.ts +33 -26
- package/src/smartfox/pro/zone/index.ts +59 -282
- package/src/smartfox/pro/zones/index.ts +3 -3
- package/src/smartfox/x2/bluebox/index.ts +149 -4
- package/src/smartfox/x2/chat/index.ts +9 -19
- package/src/smartfox/x2/codec/index.ts +31 -39
- package/src/smartfox/x2/config/index.ts +6 -1
- package/src/smartfox/x2/data/array/index.ts +96 -60
- package/src/smartfox/x2/data/object/index.ts +144 -82
- package/src/smartfox/x2/data/serializer/index.ts +41 -23
- package/src/smartfox/x2/flood/gate/index.ts +19 -13
- package/src/smartfox/x2/format/buddy/init/response/index.ts +4 -3
- package/src/smartfox/x2/format/find/rooms/response/index.ts +4 -3
- package/src/smartfox/x2/format/find/users/response/index.ts +4 -3
- package/src/smartfox/x2/format/group/subscribe/response/index.ts +4 -3
- package/src/smartfox/x2/format/login/response/index.ts +4 -3
- package/src/smartfox/x2/format/mmo/position/response/index.ts +8 -6
- package/src/smartfox/x2/format/room/join/response/index.ts +4 -3
- package/src/smartfox/x2/games/index.ts +35 -8
- package/src/smartfox/x2/hall/index.ts +0 -6
- package/src/smartfox/x2/handler/session/index.ts +1 -1
- package/src/smartfox/x2/index.ts +8 -3
- package/src/smartfox/x2/member/index.ts +10 -3
- package/src/smartfox/x2/packet/login/response/index.ts +12 -0
- package/src/smartfox/x2/protocol/index.ts +11 -1
- package/src/smartfox/x2/rooms/index.ts +1 -2
- package/src/smartfox/x2/sessions/index.ts +6 -0
- package/src/smartfox/x2/udp/index.ts +61 -24
- package/src/smartfox/x2/web/index.ts +35 -17
- package/src/smartfox/x2/websocket/index.ts +18 -36
- package/src/smartfox/x2/zone/index.ts +77 -28
- package/src/smartfox/x2/zones/index.ts +17 -5
- package/src/photon/enet/handler/index.ts +0 -65
- package/src/scale/hosted/index.ts +0 -68
- package/src/scale/outlet/index.ts +0 -121
- package/src/smartfox/pro/bluebox/gateway/index.ts +0 -310
- package/src/smartfox/pro/bluebox/session/index.ts +0 -63
- package/src/smartfox/pro/bluebox/transport/index.ts +0 -104
- package/src/smartfox/x2/bluebox/gateway/index.ts +0 -315
- /package/src/smartfox/{x2 → common}/bluebox/session/index.ts +0 -0
- /package/src/smartfox/{pro → common}/counters/index.ts +0 -0
- /package/src/smartfox/{pro → common}/counters/memory/index.ts +0 -0
- /package/src/smartfox/{pro → common}/counters/offender/index.ts +0 -0
- /package/src/smartfox/{pro → common}/counters/store/index.ts +0 -0
- /package/src/smartfox/{pro → common}/sequence/index.ts +0 -0
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AttributeKey,
|
|
3
|
-
Channel,
|
|
4
|
-
type ChannelSetup,
|
|
5
|
-
type ShardLink,
|
|
6
|
-
} from '@netifyjs/netify'
|
|
7
|
-
|
|
8
|
-
import { Courier } from '../../../../scale/courier/index.ts'
|
|
9
|
-
import { Switchboard } from '../../../../scale/switchboard/index.ts'
|
|
10
|
-
|
|
11
|
-
import { BlueBoxSession } from '../session/index.ts'
|
|
12
|
-
import { BlueBoxTransport } from '../transport/index.ts'
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* How the HTTP tunnel is set up
|
|
16
|
-
*/
|
|
17
|
-
export type BlueBoxOptions = {
|
|
18
|
-
/**
|
|
19
|
-
* Builds the pipeline of each tunnelled connection
|
|
20
|
-
*/
|
|
21
|
-
readonly setup: ChannelSetup
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Quiet time before a session is dropped, 60000 ms by default
|
|
25
|
-
*/
|
|
26
|
-
readonly timeout?: number
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Longest a poll is held open for data, 25000 ms by default
|
|
30
|
-
*/
|
|
31
|
-
readonly hold?: number
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Connects the server's shards
|
|
35
|
-
*/
|
|
36
|
-
readonly link?: ShardLink | null
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Goes in front of the link topics the tunnel uses
|
|
40
|
-
*/
|
|
41
|
-
readonly topic?: string
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* A client's request as it travels to the shard that holds its session
|
|
46
|
-
*/
|
|
47
|
-
type Forwarded = {
|
|
48
|
-
/**
|
|
49
|
-
* The form field's value
|
|
50
|
-
*/
|
|
51
|
-
readonly request: string
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Where the request came from
|
|
55
|
-
*/
|
|
56
|
-
readonly address: string
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Port the request came from
|
|
60
|
-
*/
|
|
61
|
-
readonly port: number
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Lets clients that can't open a socket talk over HTTP requests
|
|
66
|
-
* @class
|
|
67
|
-
*/
|
|
68
|
-
export class BlueBox {
|
|
69
|
-
/**
|
|
70
|
-
* Goes in front of the link topics the tunnel uses by default
|
|
71
|
-
*/
|
|
72
|
-
public static readonly topic: string = 'netify:protocol:smartfox2x:bluebox'
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Marks a connection that's tunnelled over HTTP
|
|
76
|
-
*/
|
|
77
|
-
private static readonly tunnelled: AttributeKey<boolean> =
|
|
78
|
-
new AttributeKey<boolean>('netify:protocol:smartfox2x:bluebox')
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Path the client posts to
|
|
82
|
-
*/
|
|
83
|
-
public static readonly path: string = '/BlueBox/BlueBox.do'
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Form field the client puts its request in
|
|
87
|
-
*/
|
|
88
|
-
public static readonly field: string = 'sfsHttp'
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* What a client with no session is told
|
|
92
|
-
*/
|
|
93
|
-
public static readonly lost: string = 'err01|Invalid http session !'
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* What a poll with nothing waiting is told
|
|
97
|
-
*/
|
|
98
|
-
public static readonly idle: string = 'poll|null'
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* What stands in for a missing field
|
|
102
|
-
*/
|
|
103
|
-
private static readonly nothing: string = 'null'
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Builds the pipeline of each tunnelled connection
|
|
107
|
-
*/
|
|
108
|
-
private readonly setup: ChannelSetup
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Quiet time before a session is dropped, in ms
|
|
112
|
-
*/
|
|
113
|
-
private readonly timeout: number
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Longest a poll is held open for data, in ms
|
|
117
|
-
*/
|
|
118
|
-
private readonly hold: number
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Open sessions by id
|
|
122
|
-
*/
|
|
123
|
-
private readonly sessions: Map<string, BlueBoxSession>
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Looks for quiet sessions
|
|
127
|
-
*/
|
|
128
|
-
private readonly sweeper: Timer
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Finds the shard that holds a session
|
|
132
|
-
*/
|
|
133
|
-
private readonly switchboard: Switchboard<Forwarded, string>
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* @param options how the tunnel is set up
|
|
137
|
-
*/
|
|
138
|
-
private constructor(options: BlueBoxOptions) {
|
|
139
|
-
const timeout = options.timeout ?? 60_000
|
|
140
|
-
const hold = options.hold ?? 25_000
|
|
141
|
-
if (!(timeout > 0)) throw new RangeError('Timeout is invalid')
|
|
142
|
-
if (!(hold >= 0) || hold >= timeout) throw new RangeError('Hold is invalid')
|
|
143
|
-
|
|
144
|
-
this.setup = options.setup
|
|
145
|
-
this.timeout = timeout
|
|
146
|
-
this.hold = hold
|
|
147
|
-
this.sessions = new Map<string, BlueBoxSession>()
|
|
148
|
-
this.switchboard = Switchboard.of<Forwarded, string>(
|
|
149
|
-
options.link ?? null,
|
|
150
|
-
options.topic ?? BlueBox.topic,
|
|
151
|
-
(forwarded: Forwarded): Promise<string> =>
|
|
152
|
-
this.handle(forwarded.request, forwarded.address, forwarded.port),
|
|
153
|
-
)
|
|
154
|
-
this.sweeper = setInterval(
|
|
155
|
-
(): void => {
|
|
156
|
-
void this.sweep()
|
|
157
|
-
},
|
|
158
|
-
Math.max(10, timeout / 4),
|
|
159
|
-
)
|
|
160
|
-
this.sweeper.unref()
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* A tunnel with no sessions
|
|
165
|
-
* @param options how the tunnel is set up
|
|
166
|
-
*/
|
|
167
|
-
public static of(options: BlueBoxOptions): BlueBox {
|
|
168
|
-
return new BlueBox(options)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Whether a connection is tunnelled over HTTP
|
|
173
|
-
* @param channel the connection handlers see
|
|
174
|
-
*/
|
|
175
|
-
public static carries(channel: Channel): boolean {
|
|
176
|
-
return channel.attributes.get<boolean>(BlueBox.tunnelled) === true
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* How many sessions are open
|
|
181
|
-
*/
|
|
182
|
-
public get size(): number {
|
|
183
|
-
return this.sessions.size
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Answers one request from a client
|
|
188
|
-
* @param request the form field's value
|
|
189
|
-
* @param address where the request came from
|
|
190
|
-
* @param port port the request came from
|
|
191
|
-
* @param now current time in ms
|
|
192
|
-
*/
|
|
193
|
-
public async handle(
|
|
194
|
-
request: string,
|
|
195
|
-
address: string,
|
|
196
|
-
port: number,
|
|
197
|
-
now: number = performance.now(),
|
|
198
|
-
): Promise<string> {
|
|
199
|
-
const [id = '', command = '', data = BlueBox.nothing] = request.split('|')
|
|
200
|
-
if (command === 'connect') return this.connect(address, port, now)
|
|
201
|
-
|
|
202
|
-
const elsewhere = this.switchboard.route(id, { request, address, port })
|
|
203
|
-
if (elsewhere !== null) return this.relayed(elsewhere)
|
|
204
|
-
|
|
205
|
-
const session = this.sessions.get(id)
|
|
206
|
-
if (session === undefined) return BlueBox.lost
|
|
207
|
-
|
|
208
|
-
session.seen = now
|
|
209
|
-
|
|
210
|
-
switch (command) {
|
|
211
|
-
case 'poll':
|
|
212
|
-
return this.poll(session)
|
|
213
|
-
case 'data':
|
|
214
|
-
if (data !== BlueBox.nothing) {
|
|
215
|
-
await session.channel.handleData(Buffer.from(data, 'base64'))
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return ''
|
|
219
|
-
case 'disconnect':
|
|
220
|
-
await this.drop(session)
|
|
221
|
-
return ''
|
|
222
|
-
default:
|
|
223
|
-
return ''
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Drops every session and stops looking for quiet ones
|
|
229
|
-
*/
|
|
230
|
-
public async shutdown(): Promise<void> {
|
|
231
|
-
clearInterval(this.sweeper)
|
|
232
|
-
this.switchboard.close()
|
|
233
|
-
|
|
234
|
-
for (const session of [...this.sessions.values()]) {
|
|
235
|
-
await this.drop(session)
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Opens a session and tells the client its id
|
|
241
|
-
* @param address where the request came from
|
|
242
|
-
* @param port port the request came from
|
|
243
|
-
* @param now current time in ms
|
|
244
|
-
*/
|
|
245
|
-
private async connect(
|
|
246
|
-
address: string,
|
|
247
|
-
port: number,
|
|
248
|
-
now: number,
|
|
249
|
-
): Promise<string> {
|
|
250
|
-
const id = this.switchboard.mint()
|
|
251
|
-
const transport = new BlueBoxTransport(address, port)
|
|
252
|
-
const channel = new Channel(transport)
|
|
253
|
-
channel.attributes.set<boolean>(BlueBox.tunnelled, true)
|
|
254
|
-
|
|
255
|
-
this.sessions.set(id, BlueBoxSession.of(id, channel, transport, now))
|
|
256
|
-
await channel.activate(this.setup)
|
|
257
|
-
|
|
258
|
-
return `connect|${id}`
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* The answer of the shard that holds a session
|
|
263
|
-
* @param answer what that shard is asked
|
|
264
|
-
*/
|
|
265
|
-
private async relayed(answer: Promise<string>): Promise<string> {
|
|
266
|
-
try {
|
|
267
|
-
return await answer
|
|
268
|
-
} catch (cause) {
|
|
269
|
-
if (cause instanceof Error && cause.message === Courier.down) {
|
|
270
|
-
return BlueBox.lost
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
throw new Error('Tunnel request failed', { cause })
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Hands a client everything that's waiting for it
|
|
279
|
-
* @param session who's polling
|
|
280
|
-
*/
|
|
281
|
-
private async poll(session: BlueBoxSession): Promise<string> {
|
|
282
|
-
const waiting = await session.transport.take(this.hold)
|
|
283
|
-
session.seen = performance.now()
|
|
284
|
-
|
|
285
|
-
if (waiting.length > 0) {
|
|
286
|
-
return `poll|${Buffer.from(waiting).toString('base64')}`
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (!session.transport.ended) return BlueBox.idle
|
|
290
|
-
|
|
291
|
-
await this.drop(session)
|
|
292
|
-
return BlueBox.lost
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Closes a session's connection and forgets it
|
|
297
|
-
* @param session what to drop
|
|
298
|
-
*/
|
|
299
|
-
private async drop(session: BlueBoxSession): Promise<void> {
|
|
300
|
-
if (!this.sessions.delete(session.id)) return
|
|
301
|
-
|
|
302
|
-
session.transport.end()
|
|
303
|
-
await session.channel.handleClose()
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Drops sessions that stopped polling
|
|
308
|
-
* @param now current time in ms
|
|
309
|
-
*/
|
|
310
|
-
private async sweep(now: number = performance.now()): Promise<void> {
|
|
311
|
-
for (const session of [...this.sessions.values()]) {
|
|
312
|
-
if (now - session.seen >= this.timeout) await this.drop(session)
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|