libp2r2p 0.10.24 → 0.10.25
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 +1 -1
- package/relay/services/relay-pool.js +12 -2
package/package.json
CHANGED
|
@@ -136,13 +136,23 @@ export class RelayPool {
|
|
|
136
136
|
#liveSubCounts = new Map() // url -> number of active live subscriptions
|
|
137
137
|
#timeout = 30000 // 30 seconds
|
|
138
138
|
#createRelay
|
|
139
|
+
#WebSocket
|
|
139
140
|
#admission
|
|
140
141
|
|
|
141
|
-
constructor ({ _createRelay
|
|
142
|
-
this.#
|
|
142
|
+
constructor ({ _createRelay, WebSocket: WebSocketImpl, ...capacity } = {}) {
|
|
143
|
+
this.#WebSocket = WebSocketImpl
|
|
144
|
+
this.#createRelay = _createRelay ?? (url => new RelayConnection(url, this.#WebSocket ? { WebSocket: this.#WebSocket } : undefined))
|
|
143
145
|
this.#admission = new ReadAdmission(capacity)
|
|
144
146
|
}
|
|
145
147
|
|
|
148
|
+
// Injects the WebSocket implementation used by new pooled connections (e.g.
|
|
149
|
+
// a launcher-owned relay multiplexer). Existing connections keep the
|
|
150
|
+
// implementation they were created with.
|
|
151
|
+
setWebSocket (WebSocketImpl) {
|
|
152
|
+
if (typeof WebSocketImpl !== 'function') throw new ValidationError('INVALID_WEBSOCKET_IMPLEMENTATION')
|
|
153
|
+
this.#WebSocket = WebSocketImpl
|
|
154
|
+
}
|
|
155
|
+
|
|
146
156
|
#scheduleIdleDisconnect (url) {
|
|
147
157
|
clearTimeout(this.#relayTimeouts.get(url))
|
|
148
158
|
this.#relayTimeouts.set(url, maybeUnref(setTimeout(() => {
|