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

feat: WebSocketStar #1090

Merged
merged 1 commit into from
Nov 27, 2017
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
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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following on the comment -- libp2p/js-libp2p#122 (comment) --, this actually should totally work now because websocket-star becomes part of the set of transports supported by default //cc @patrickdet @Beanow

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