All Projects → dcposch → Webtorrent Remote

dcposch / Webtorrent Remote

Run WebTorrent in one process, control it from another process or even another machine

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Webtorrent Remote

live-torrent-backend
The backend server for the live-torrent project
Stars: ✭ 38 (+2.7%)
Mutual labels:  torrent, webtorrent
Create Torrent
Create .torrent files
Stars: ✭ 264 (+613.51%)
Mutual labels:  torrent, webtorrent
parse-torrent-file
DEPRECATED: Parse a .torrent file and return an object of keys/values
Stars: ✭ 62 (+67.57%)
Mutual labels:  torrent, webtorrent
ut pex
Implementation of ut_pex bittorrent protocol (PEX) for webtorrent
Stars: ✭ 54 (+45.95%)
Mutual labels:  torrent, webtorrent
Webtorrent Hybrid
WebTorrent (with WebRTC support in Node.js)
Stars: ✭ 422 (+1040.54%)
Mutual labels:  torrent, webtorrent
CheckWebPeer
Check WebRTC peers of torrents.
Stars: ✭ 19 (-48.65%)
Mutual labels:  torrent, webtorrent
Diffy
🎞️💓🍿 Love streaming - It's always best to watch a movie together ! 🤗
Stars: ✭ 37 (+0%)
Mutual labels:  torrent, webtorrent
Wt Tracker
High-performance WebTorrent tracker
Stars: ✭ 144 (+289.19%)
Mutual labels:  torrent, webtorrent
Magnet Player
🎥 A place for streaming torrents directly from your browser
Stars: ✭ 346 (+835.14%)
Mutual labels:  torrent, webtorrent
Parse Torrent
Parse a torrent identifier (magnet uri, .torrent file, info hash)
Stars: ✭ 325 (+778.38%)
Mutual labels:  torrent, webtorrent
Magnet Uri
Parse a magnet URI and return an object of keys/values
Stars: ✭ 183 (+394.59%)
Mutual labels:  torrent, webtorrent
Webtorrent
⚡️ Streaming torrent client for the web
Stars: ✭ 25,554 (+68964.86%)
Mutual labels:  torrent, webtorrent
Torrent Discovery
Discover BitTorrent and WebTorrent peers
Stars: ✭ 177 (+378.38%)
Mutual labels:  torrent, webtorrent
webtorrent-health
💚 Get health info about a webtorrent file or magnet link
Stars: ✭ 27 (-27.03%)
Mutual labels:  torrent, webtorrent
Torrentpier
Main project repository
Stars: ✭ 166 (+348.65%)
Mutual labels:  torrent, webtorrent
BitStream
A rudimentary Electron application that utilises WebTorrent to stream and download a torrent simultaneously
Stars: ✭ 15 (-59.46%)
Mutual labels:  torrent, webtorrent
Bittorrent Tracker
🌊 Simple, robust, BitTorrent tracker (client & server) implementation
Stars: ✭ 1,184 (+3100%)
Mutual labels:  torrent, webtorrent
Nile.js
Server
Stars: ✭ 1,757 (+4648.65%)
Mutual labels:  torrent, webtorrent
Bittorrent Protocol
Simple, robust, BitTorrent peer wire protocol implementation
Stars: ✭ 279 (+654.05%)
Mutual labels:  torrent, webtorrent
Live Torrent
Torrent Web Client
Stars: ✭ 546 (+1375.68%)
Mutual labels:  torrent, webtorrent

webtorrent-remote npm downloads javascript style guide

run WebTorrent in one process, control it from another process or even another machine.

plain Javascript, no es6

server process

var WebTorrentRemoteServer = require('webtorrent-remote/server')

var opts = null
var server = new WebTorrentRemoteServer(send, opts)

function send (message) {
  // Send `message` to the correct client. It's JSON serializable.
  // Use TCP, some kind of IPC, whatever.
  // If there are multiple clients, look at message.clientKey
}

// When messages come back from the IPC channel, call:
server.receive(message)

server options

opts.heartbeatTimeout

remove clients if we don't hear a heartbeat for this many milliseconds. default 30000 (30 seconds). set to 0 to disable the heartbeat check. once a torrent has no remaining clients, it will be removed. once there are no remaining torrents, the whole webtorrent instance will be destroyed. the webtorrent instance is created lazily the first time a client calls add().

opts.updateInterval

send progress updates every x milliseconds to all clients of all torrents. default 1000 (1 second). set to 0 to disable progress updates.

other options

all WebTorrent options. the options object is passed to the constructor for the underlying WebTorrent instance.

debugging

This package uses debug for debug logging. Set the environment variable DEBUG=webtorrent-remote for detailed debug logs.

client process(es)

var WebTorrentRemoteClient = require('webtorrent-remote/client')

var opts = null
var client = new WebTorrentRemoteClient(send, opts)

function send (message) {
  // Same as above, except send the message to the server process
}

// When messages come back from the server, call:
client.receive(message)

// Now `client` is a drop-in replacement for the normal WebTorrent object!
var torrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d'
client.add(torrentId, function (err, torrent) {
  torrent.on('metadata', function () {
    console.log(JSON.stringify(torrent.files))
    // Prints [{name:'sintel.mp4'}]
  })

  var server = torrent.createServer()
  server.listen(function () {
    console.log('http://localhost:' + server.address().port)
    // Paste that into your browser to stream Sintel!
  })
})

client options

opts.heartbeat

send a heartbeat once every x milliseconds. default 5000 (5 seconds). set to 0 to disable heartbeats.

client methods

client.add(torrentID, [options], callback)

like WebTorrent.add, but only async. calls back with (err, torrent). The torrent is a torrent object (see below for methods).

client.get(torrentID, callback)

like WebTorrent.get, but async. calls back with (err, torrent). if the torrentId is not yet in the client, err.name will be 'TorrentMissingError'.

client.destroy()

like WebTorrent.destroy, but destroys only this client. if a given torrent has no clients left, it will be destroyed too. if all torrents are gone, the whole WebTorrent instance will be destroyed on the server side.

client events, from webtorrent

  • client.on('error', () => {...})
  • client.on('warning', () => {...})

torrent methods

the client gives you a torrent object in the callback to get or add. this supports a subset of the WebTorrent API, forwarding commands to the WebTorrentRemoteServer and emitting events:

torrent.createServer()

create a local torrent-to-HTTP streaming server.

torrent events, unique to webtorrent-remote, not in webtorrent

  • torrent.on('update', () => {...}): fires periodically, see updateInterval

torrent events, from webtorrent

  • torrent.on('infohash', () => {...})
  • torrent.on('metadata', () => {...})
  • torrent.on('download', () => {...})
  • torrent.on('upload', () => {...})
  • torrent.on('done', () => {...})
  • torrent.on('error', () => {...})
  • torrent.on('warning', () => {...})

torrent props unique to webtorrent-remote, not in webtorrent

  • torrent.client: the WebTorrentRemoteClient
  • torrent.key: the clientKey used for messaging

torrent props, from webtorrent (updated once on infohash or metadata)

  • torrent.infoHash
  • torrent.name
  • torrent.length
  • torrent.files

torrent props, from webtorrent (updated on every progress event)

  • torrent.progress
  • torrent.downloaded
  • torrent.uploaded
  • torrent.downloadSpeed
  • torrent.uploadSpeed
  • torrent.numPeers
  • torrent.progress
  • torrent.timeRemaining

server methods

server.address()

gets an address object like { address: '::', family: 'IPv6', port: 52505 } that shows what host and port the server is listening on.

server.listen(onlistening)

tells the server to start listening. the onlistening function is called when the server starts listening.

server events

  • server.on('listening', () => {...})
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].