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

Commit 33e9949

Browse files
mkg20001daviddias
authored andcommittedNov 27, 2017
feat: WebSocketStar (#1090)
1 parent 9c29a23 commit 33e9949

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed
 

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
"libp2p-secio": "~0.8.1",
130130
"libp2p-tcp": "~0.11.1",
131131
"libp2p-webrtc-star": "~0.13.2",
132+
"libp2p-websocket-star": "^0.5.1",
132133
"libp2p-websockets": "~0.10.4",
133134
"lodash.flatmap": "^4.5.0",
134135
"lodash.get": "^4.4.2",

‎src/core/runtime/libp2p-browser.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const WS = require('libp2p-websockets')
44
const WebRTCStar = require('libp2p-webrtc-star')
5+
const WebSocketStar = require('libp2p-websocket-star')
56
const Multiplex = require('libp2p-multiplex')
67
const SECIO = require('libp2p-secio')
78
const Railing = require('libp2p-railing')
@@ -11,14 +12,15 @@ class Node extends libp2p {
1112
constructor (peerInfo, peerBook, options) {
1213
options = options || {}
1314
const wstar = new WebRTCStar()
15+
const wsstar = new WebSocketStar({id: peerInfo.id})
1416

1517
const modules = {
16-
transport: [new WS(), wstar],
18+
transport: [new WS(), wstar, wsstar],
1719
connection: {
1820
muxer: [Multiplex],
1921
crypto: [SECIO]
2022
},
21-
discovery: [wstar.discovery]
23+
discovery: [wstar.discovery, wsstar.discovery]
2224
}
2325

2426
if (options.bootstrap) {

‎src/core/runtime/libp2p-nodejs.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const TCP = require('libp2p-tcp')
44
const MulticastDNS = require('libp2p-mdns')
55
const WS = require('libp2p-websockets')
6+
const WebSocketStar = require('libp2p-websocket-star')
67
const Railing = require('libp2p-railing')
78
const KadDHT = require('libp2p-kad-dht')
89
const Multiplex = require('libp2p-multiplex')
@@ -12,14 +13,15 @@ const libp2p = require('libp2p')
1213
class Node extends libp2p {
1314
constructor (peerInfo, peerBook, options) {
1415
options = options || {}
16+
const wsstar = new WebSocketStar({id: peerInfo.id})
1517

1618
const modules = {
17-
transport: [new TCP(), new WS()],
19+
transport: [new TCP(), new WS(), wsstar],
1820
connection: {
1921
muxer: [Multiplex],
2022
crypto: [SECIO]
2123
},
22-
discovery: []
24+
discovery: [wsstar.discovery]
2325
}
2426

2527
if (options.dht) {

0 commit comments

Comments
 (0)
This repository has been archived.