Skip to content

Commit

Permalink
Merge pull request #83 from surprisetalk/master
Browse files Browse the repository at this point in the history
Replaced `electron-webrtc` with `wrtc`.
  • Loading branch information
DiegoRBaquero authored Dec 11, 2018
2 parents c0e5153 + 54618f0 commit 90bab0e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 92 deletions.
35 changes: 0 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@

In node.js, the `webtorrent` package only connects to normal TCP/UDP peers, not WebRTC peers. If you want to connect to all types of peers, including WebRTC peers, from node.js, you need to use this package (`webtorrent-hybrid`).

Previous versions (0.x) of this package used [wrtc](https://github.com/js-platform/node-webrtc), a WebRTC implementation via native extensions, the current one is based on [electron-webrtc](https://github.com/mappum/electron-webrtc) (which in turn uses [electron-prebuilt](https://github.com/electron-userland/electron-prebuilt)) for better compatibility. It creates a hidden Electron process (which is based on Chromium, so WebRTC support is great!) and communicates with that process to enable WebRTC in Node.js. This adds a lot of overhead, so we are looking forward to using a pure JavaScript implementation, like perhaps [Node-RTCPeerConnection](https://github.com/nickdesaulniers/node-rtc-peer-connection) when it's ready.

To run this package on a headless server execute [the provided script](bin/prepareHeadless.sh) or follow [these instructions](https://github.com/mappum/electron-webrtc#running-on-a-headless-server).

## Install

To install WebTorrent:
Expand All @@ -31,37 +27,6 @@ To install a `webtorrent-hybrid` command line program, run:
npm install webtorrent-hybrid -g
```

### OS X

On OS X, this should Just Work™.

### Linux

The current version of `webtorrent-hybrid` requires a screen, since the headless Electron
instance expects one. If you're running in a screenless environment (like on a server),
you must use a virtual screen such as `xvfb`. You must install it before using
`webtorrent-hybrid`.

#### For Debian / Ubuntu:

```bash
sudo apt-get install xvfb
```

If you get an error about a missing .so file ("error while loading shared libraries"), use the search at the bottom of [packages.debian.org](https://packages.debian.org) to find out which packages in your release provide a given file.

On server editions, the following additional packages should be installed since Electron depends on them:

```bash
sudo apt-get install libgtk2.0-0 libxtst-dev libxss-dev libgconf2-dev libnss3 libasound2-dev
```

#### For CentOS / RHEL:

```bash
sudo yum install xorg-x11-server-Xvfb
```

## Usage

`webtorrent-hybrid` has the same command line interface (CLI) and module API as
Expand Down
32 changes: 0 additions & 32 deletions bin/prepareHeadless.sh

This file was deleted.

23 changes: 2 additions & 21 deletions lib/global.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,8 @@
const createTorrent = require('create-torrent')
const ElectronWebRTC = require('electron-webrtc')
const wrtc = require('wrtc')

global.WEBTORRENT_ANNOUNCE = createTorrent.announceList
.map(arr => arr[0])
.filter(url => url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0)

global.WRTC = () => {
const wrtc = ElectronWebRTC()

const ensureCloseElectron = () => {
process.removeListener('SIGINT', ensureCloseElectron)
process.removeListener('SIGTERM', ensureCloseElectron)
wrtc.close()
}

process.on('SIGINT', ensureCloseElectron)
process.on('SIGTERM', ensureCloseElectron)

wrtc.on('error', (err, source) => {
if (err.message !== 'Daemon already closed') {
console.error(err, source)
}
})

return wrtc
}
global.WRTC = wrtc
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"url": "https://github.com/webtorrent/webtorrent-hybrid/issues"
},
"dependencies": {
"create-torrent": "^3.23.1",
"electron-webrtc": "^0.3.0",
"webtorrent": "0.x",
"webtorrent-cli": "^1.0.1"
"create-torrent": "^3.33.0",
"webtorrent": "^0.102.4",
"webtorrent-cli": "^1.12.3",
"wrtc": "^0.2.1"
},
"devDependencies": {
"standard": "*"
Expand Down

0 comments on commit 90bab0e

Please sign in to comment.