Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Act gracefully when a client has aborted at an inconvenient time and
we try to forward an offer to them.
  • Loading branch information
prozacchiwawa committed Jul 22, 2015
commit dee1c226c19b39638f9db43a0e3122cf7d57c6d8
19 changes: 12 additions & 7 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,18 @@ Server.prototype._onWebSocketRequest = function (socket, params) {
debug('got offers %s from %s', JSON.stringify(params.offers), params.peer_id)
debug('got %s peers from swarm %s', peers.length, params.info_hash)
peers.forEach(function (peer, i) {
peer.socket.send(JSON.stringify({
offer: params.offers[i].offer,
offer_id: params.offers[i].offer_id,
peer_id: common.hexToBinary(params.peer_id),
info_hash: common.hexToBinary(params.info_hash)
}))
debug('sent offer to %s from %s', peer.peerId, params.peer_id)
var data_for_peer = JSON.stringify({
offer: params.offers[i].offer,
offer_id: params.offers[i].offer_id,
peer_id: common.hexToBinary(params.peer_id),
info_hash: common.hexToBinary(params.info_hash)
})
try {
peer.socket.send(data_for_peer);
debug('sent offer to %s from %s', peer.peerId, params.peer_id)
} catch (ex) {
debug('error sending to peer %s: %s', peer.peerId, ex)
}
})
}

Expand Down