mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-26 07:21:36 +00:00
feat: support custom listener options (#822)
* support custom listener options * fix get listener options * add doc to explain custom listener options * add ut * fix code style * Apply suggestions from code review Co-authored-by: Vasco Santos <vasco.santos@ua.pt> * add missing comma Co-authored-by: Vasco Santos <vasco.santos@ua.pt>
This commit is contained in:
@ -20,6 +20,7 @@ class TransportManager {
|
||||
this.upgrader = upgrader
|
||||
this._transports = new Map()
|
||||
this._listeners = new Map()
|
||||
this._listenerOptions = new Map()
|
||||
this.faultTolerance = faultTolerance
|
||||
}
|
||||
|
||||
@ -47,6 +48,7 @@ class TransportManager {
|
||||
})
|
||||
|
||||
this._transports.set(key, transport)
|
||||
this._listenerOptions.set(key, transportOptions.listenerOptions || {})
|
||||
if (!this._listeners.has(key)) {
|
||||
this._listeners.set(key, [])
|
||||
}
|
||||
@ -154,7 +156,7 @@ class TransportManager {
|
||||
// For each supported multiaddr, create a listener
|
||||
for (const addr of supportedAddrs) {
|
||||
log('creating listener for %s on %s', key, addr)
|
||||
const listener = transport.createListener({}, this.onConnection)
|
||||
const listener = transport.createListener(this._listenerOptions.get(key), this.onConnection)
|
||||
this._listeners.get(key).push(listener)
|
||||
|
||||
// We need to attempt to listen on everything
|
||||
|
Reference in New Issue
Block a user