Skip to content
This repository was archived by the owner on Apr 24, 2023. It is now read-only.

Commit 55fb9ad

Browse files
committed
chore: use multiaddr-conn
1 parent c194bc4 commit 55fb9ad

20 files changed

+441
-323
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
include:
2020
- stage: check
2121
script:
22+
- npx aegir build --bundlesize
2223
- npx aegir dep-check -- -i wrtc -i electron-webrtc
2324
- npm run lint
2425

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,35 @@ const ws2 = new WStar({ wrtc: electronWebRTC() })
5454

5555
```JavaScript
5656
const WStar = require('libp2p-webrtc-star')
57+
const multiaddr = require('multiaddr')
58+
const pipe = require('it-pipe')
59+
const { collect } = require('streaming-iterables')
5760

58-
const ws = new WStar()
61+
const addr = multiaddr('/ip4/188.166.203.82/tcp/20000/wss/p2p-webrtc-star/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSooo2a')
62+
63+
const ws = new WStar({ upgrader })
64+
65+
const listener = ws.createListener((socket) => {
66+
console.log('new connection opened')
67+
pipe(
68+
['hello'],
69+
socket
70+
)
71+
})
72+
73+
await listener.listen(addr)
74+
console.log('listening')
75+
76+
const socket = await ws.dial(addr)
77+
const values = await pipe(
78+
socket,
79+
collect
80+
)
81+
82+
console.log(`Value: ${values.toString()}`)
83+
84+
// Close connection after reading
85+
await listener.close()
5986
```
6087

6188
## API

package.json

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"coverage-publish": "aegir coverage --provider coveralls"
2626
},
2727
"pre-push": [
28-
"test"
28+
"lint"
2929
],
3030
"engines": {
3131
"node": ">=10.0.0",
@@ -45,32 +45,34 @@
4545
},
4646
"homepage": "https://github.com/libp2p/js-libp2p-webrtc-star#readme",
4747
"devDependencies": {
48-
"aegir": "^20.0.0",
48+
"aegir": "^20.3.1",
4949
"chai": "^4.2.0",
5050
"dirty-chai": "^2.0.1",
5151
"electron-webrtc": "~0.3.0",
52+
"interface-peer-discovery": "github:libp2p/interface-peer-discovery#refactor/async",
53+
"interface-transport": "^0.7.0",
5254
"prom-client": "^11.5.3",
53-
"wrtc": "~0.4.1"
55+
"wrtc": "~0.4.2"
5456
},
5557
"dependencies": {
56-
"@hapi/hapi": "^18.3.2",
57-
"@hapi/inert": "^5.2.1",
58+
"@hapi/hapi": "^18.4.0",
59+
"@hapi/inert": "^5.2.2",
5860
"abortable-iterator": "^2.1.0",
5961
"class-is": "^1.1.0",
6062
"debug": "^4.1.1",
6163
"epimetheus": "^1.0.92",
6264
"err-code": "^2.0.0",
63-
"interface-connection": "~0.3.3",
64-
"interface-transport": "^0.5.2",
6565
"it-pipe": "^1.0.1",
66-
"mafmt": "^6.0.8",
66+
"libp2p-utils": "^0.1.0",
67+
"mafmt": "^7.0.0",
6768
"minimist": "^1.2.0",
68-
"multiaddr": "^6.1.0",
69+
"multiaddr": "^7.1.0",
6970
"peer-id": "~0.13.2",
70-
"peer-info": "~0.16.0",
71-
"simple-peer": "^9.5.0",
72-
"socket.io": "^2.2.0",
73-
"socket.io-client": "^2.2.0",
71+
"peer-info": "~0.17.0",
72+
"simple-peer": "^9.6.0",
73+
"socket.io": "^2.3.0",
74+
"socket.io-client": "^2.3.0",
75+
"stream-to-it": "^0.1.1",
7476
"streaming-iterables": "^4.1.0",
7577
"webrtcsupport": "github:ipfs/webrtcsupport"
7678
},

src/adapter.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/constants.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
'use strict'
22

3-
// Time to wait for a connection to close gracefully before destroying it
4-
// manually
5-
module.exports.CLOSE_TIMEOUT = 2000
3+
// p2p multi-address code
4+
exports.CODE_P2P = 421
5+
exports.CODE_CIRCUIT = 290
6+
7+
// Time to wait for a connection to close gracefully before destroying it manually
8+
exports.CLOSE_TIMEOUT = 2000

0 commit comments

Comments
 (0)