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

Commit

Permalink
chore: use multiaddr-conn
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Sep 30, 2019
1 parent c194bc4 commit 0e0eef2
Show file tree
Hide file tree
Showing 19 changed files with 442 additions and 323 deletions.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,35 @@ const ws2 = new WStar({ wrtc: electronWebRTC() })

```JavaScript
const WStar = require('libp2p-webrtc-star')
const multiaddr = require('multiaddr')
const pipe = require('it-pipe')
const { collect } = require('streaming-iterables')

const ws = new WStar()
const addr = multiaddr('/ip4/188.166.203.82/tcp/20000/wss/p2p-webrtc-star/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSooo2a')

const ws = new WStar({ upgrader })

const listener = ws.createListener((socket) => {
console.log('new connection opened')
pipe(
['hello'],
socket
)
})

await listener.listen(addr)
console.log('listening')

const socket = await ws.dial(addr)
const values = await pipe(
socket,
collect
)

console.log(`Value: ${values.toString()}`)

// Close connection after reading
await listener.close()
```

## API
Expand Down
28 changes: 15 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"coverage-publish": "aegir coverage --provider coveralls"
},
"pre-push": [
"test"
"lint"
],
"engines": {
"node": ">=10.0.0",
Expand All @@ -45,32 +45,34 @@
},
"homepage": "https://github.com/libp2p/js-libp2p-webrtc-star#readme",
"devDependencies": {
"aegir": "^20.0.0",
"aegir": "^20.3.1",
"chai": "^4.2.0",
"dirty-chai": "^2.0.1",
"electron-webrtc": "~0.3.0",
"interface-discovery": "~0.1.1",
"interface-transport": "libp2p/interface-transport#chore/skip-abort-while-reading-for-webrtc",
"prom-client": "^11.5.3",
"wrtc": "~0.4.1"
"wrtc": "~0.4.2"
},
"dependencies": {
"@hapi/hapi": "^18.3.2",
"@hapi/inert": "^5.2.1",
"@hapi/hapi": "^18.4.0",
"@hapi/inert": "^5.2.2",
"abortable-iterator": "^2.1.0",
"class-is": "^1.1.0",
"debug": "^4.1.1",
"epimetheus": "^1.0.92",
"err-code": "^2.0.0",
"interface-connection": "~0.3.3",
"interface-transport": "^0.5.2",
"it-pipe": "^1.0.1",
"mafmt": "^6.0.8",
"libp2p-utils": "^0.1.0",
"mafmt": "^7.0.0",
"minimist": "^1.2.0",
"multiaddr": "^6.1.0",
"multiaddr": "^7.1.0",
"peer-id": "~0.13.2",
"peer-info": "~0.16.0",
"simple-peer": "^9.5.0",
"socket.io": "^2.2.0",
"socket.io-client": "^2.2.0",
"peer-info": "~0.17.0",
"simple-peer": "^9.6.0",
"socket.io": "^2.3.0",
"socket.io-client": "^2.3.0",
"stream-to-it": "^0.1.1",
"streaming-iterables": "^4.1.0",
"webrtcsupport": "github:ipfs/webrtcsupport"
},
Expand Down
17 changes: 0 additions & 17 deletions src/adapter.js

This file was deleted.

9 changes: 6 additions & 3 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
'use strict'

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

// Time to wait for a connection to close gracefully before destroying it manually
exports.CLOSE_TIMEOUT = 2000
Loading

0 comments on commit 0e0eef2

Please sign in to comment.