Browse Source

getter for getting the active socket

session-estimator
Mathias Buus 3 years ago
parent
commit
edb281f71a
  1. 6
      index.js

6
index.js

@ -78,6 +78,10 @@ class DHT extends EventEmitter {
return this._nat.port return this._nat.port
} }
get socket () {
return this.firewalled ? this.io.clientSocket : this.io.serverSocket
}
onmessage (socket, buf, rinfo) { onmessage (socket, buf, rinfo) {
if (buf.byteLength > 1) this.io.onmessage(socket, buf, rinfo) if (buf.byteLength > 1) this.io.onmessage(socket, buf, rinfo)
} }
@ -87,7 +91,7 @@ class DHT extends EventEmitter {
} }
address () { address () {
const socket = this.firewalled ? this.io.clientSocket : this.io.serverSocket const socket = this.socket
return socket ? socket.address() : null return socket ? socket.address() : null
} }

Loading…
Cancel
Save