Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ability to close and restore streaming server #1547

Merged
merged 2 commits into from Jun 11, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

ability to close and restore streamin server

  • Loading branch information
untitledlt committed Nov 22, 2018
commit 144812c09316d9016a87d6a8e5096ddb7fbf5f63
@@ -12,11 +12,16 @@ function Server (torrent, opts = {}) {
const sockets = []
const pendingReady = []
let closed = false
const _listen = server.listen
const _close = server.close

server.on('connection', onConnection)
server.on('request', onRequest)
server.listen = port => {
closed = false
server.on('connection', onConnection)
server.on('request', onRequest)
_listen.call(server, port)

This comment has been minimized.

Copy link
@alxhotel

alxhotel Apr 7, 2019

Member

In order to make this compatible and pass the tests, it should be changed to:

server.listen = (...args) => {
  ...
  _listen.apply(server, args)
}
}

const _close = server.close
server.close = cb => {
closed = true
server.removeListener('connection', onConnection)
@@ -25,7 +30,6 @@ function Server (torrent, opts = {}) {
const onReady = pendingReady.pop()
torrent.removeListener('ready', onReady)
}
torrent = null

This comment has been minimized.

Copy link
@alxhotel

alxhotel Apr 7, 2019

Member

Move torrent = null inside server.destroy(cb).

_close.call(server, cb)
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.