Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/conn-pool.js')
-rw-r--r--lib/conn-pool.js18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/conn-pool.js b/lib/conn-pool.js
index 1c6ac79..77e27df 100644
--- a/lib/conn-pool.js
+++ b/lib/conn-pool.js
@@ -1,9 +1,9 @@
-const net = require('net') // browser exclude
-const debugFactory = require('debug')
-const queueMicrotask = require('queue-microtask')
+import net from 'net' // browser exclude
+import debugFactory from 'debug'
+import queueMicrotask from 'queue-microtask'
-const Peer = require('./peer.js')
-const utp = require('./utp.js') // browser exclude
+import Peer from './peer.js'
+import utp from './utp.js' // browser exclude
const debug = debugFactory('webtorrent:conn-pool')
@@ -16,7 +16,7 @@ const debug = debugFactory('webtorrent:conn-pool')
*
* @param {number} port
*/
-class ConnPool {
+export default class ConnPool {
constructor (client) {
debug('create pool (port %s)', client.torrentPort)
@@ -52,11 +52,11 @@ class ConnPool {
this.tcpServer.on('error', this._onTCPError)
// Start TCP
- this.tcpServer.listen(client.torrentPort, () => {
+ this.tcpServer.listen(client.torrentPort, async () => {
debug('creating tcpServer in port %s', this.tcpServer.address().port)
if (this._client.utp) {
// Setup uTP
- this.utpServer = utp.createServer()
+ this.utpServer = (await utp).createServer()
this.utpServer.on('connection', this._onUTPConnectionBound)
this.utpServer.on('listening', this._onListening)
this.utpServer.on('error', this._onUTPError)
@@ -184,5 +184,3 @@ class ConnPool {
ConnPool.UTP_SUPPORT = Object.keys(utp).length > 0
function noop () {}
-
-module.exports = ConnPool