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

docs: add upgrader to readme example #114

Merged
merged 1 commit into from
Sep 20, 2019
Merged
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
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ const multiaddr = require('multiaddr')
const pipe = require('it-pipe')
const { collect } = require('streaming-iterables')

const addr = multiaddr('/ip4/127.0.0.1/tcp/9090')
// A simple upgrader that just returns the MultiaddrConnection
const upgrader = {
upgradeInbound: maConn => maConn,
upgradeOutbound: maConn => maConn
}

const tcp = new TCP()
const tcp = new TCP({ upgrader })

const listener = tcp.createListener((socket) => {
console.log('new connection opened')
Expand All @@ -56,6 +60,7 @@ const listener = tcp.createListener((socket) => {
)
})

const addr = multiaddr('/ip4/127.0.0.1/tcp/9090')
await listener.listen(addr)
console.log('listening')

Expand Down