Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
feat: WebSocketStar (#1090)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkg20001 authored and daviddias committed Nov 27, 2017
1 parent 9c29a23 commit 33e9949
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
"libp2p-secio": "~0.8.1",
"libp2p-tcp": "~0.11.1",
"libp2p-webrtc-star": "~0.13.2",
"libp2p-websocket-star": "^0.5.1",
"libp2p-websockets": "~0.10.4",
"lodash.flatmap": "^4.5.0",
"lodash.get": "^4.4.2",
Expand Down
6 changes: 4 additions & 2 deletions src/core/runtime/libp2p-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const WS = require('libp2p-websockets')
const WebRTCStar = require('libp2p-webrtc-star')
const WebSocketStar = require('libp2p-websocket-star')
const Multiplex = require('libp2p-multiplex')
const SECIO = require('libp2p-secio')
const Railing = require('libp2p-railing')
Expand All @@ -11,14 +12,15 @@ class Node extends libp2p {
constructor (peerInfo, peerBook, options) {
options = options || {}
const wstar = new WebRTCStar()
const wsstar = new WebSocketStar({id: peerInfo.id})

const modules = {
transport: [new WS(), wstar],
transport: [new WS(), wstar, wsstar],
connection: {
muxer: [Multiplex],
crypto: [SECIO]
},
discovery: [wstar.discovery]
discovery: [wstar.discovery, wsstar.discovery]
}

if (options.bootstrap) {
Expand Down
6 changes: 4 additions & 2 deletions src/core/runtime/libp2p-nodejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const TCP = require('libp2p-tcp')
const MulticastDNS = require('libp2p-mdns')
const WS = require('libp2p-websockets')
const WebSocketStar = require('libp2p-websocket-star')
const Railing = require('libp2p-railing')
const KadDHT = require('libp2p-kad-dht')
const Multiplex = require('libp2p-multiplex')
Expand All @@ -12,14 +13,15 @@ const libp2p = require('libp2p')
class Node extends libp2p {
constructor (peerInfo, peerBook, options) {
options = options || {}
const wsstar = new WebSocketStar({id: peerInfo.id})

const modules = {
transport: [new TCP(), new WS()],
transport: [new TCP(), new WS(), wsstar],
connection: {
muxer: [Multiplex],
crypto: [SECIO]
},
discovery: []
discovery: [wsstar.discovery]
}

if (options.dht) {
Expand Down

0 comments on commit 33e9949

Please sign in to comment.