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

Replaced electron-webrtc with wrtc. #83

Merged
merged 3 commits into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
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
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