An open API service indexing awesome lists of open source software.

https://github.com/soyuka/native-messaging-swarm

TCP/UDP swarm on top of WebExtension's native messaging protocol
https://github.com/soyuka/native-messaging-swarm

bridge dat-project hyperdrive swarm tcp udp

Last synced: about 2 months ago
JSON representation

TCP/UDP swarm on top of WebExtension's native messaging protocol

Awesome Lists containing this project

README

          

Native messaging swarm
======================

A swarm library that would allow to replicate a dat stream thorugh tcp/udp from the browser. It uses WebExtension's native messaging protocol.

## Installation

```
npm install native-messaging-swarm
```

## Usage

```javascript
const runtime = require('browser.runtime') // or window.runtime
const hyperdrive = require('hyperdrive')
const swarm = require('native-messaging-swarm')

const archive = hyperdrive('./test')
const port = runtime.connectNative(`${__dirname}/native.js`)

archive.ready(() => {
// shares the archive through tcp/udp from the native app
swarm(archive, port)
})
```

## Example

Thanks to `browser.runtime`, on nodejs it'll `spawn` a new process that mimics the native messaging app. In the future the native app can be packaged (https://github.com/zeit/pkg) and would work through a native messaging manifest (see [WebExtensions](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Native_messaging)).

Test this already by launching `node example.js`. It'll start an archive with a `dat.json` and share it through `hyperdiscovery` with the native app.
To clone using `hyperdiscovery` use `node clone.js [key]`.