diff --git a/README.md b/README.md index a4acbb9..94b8f49 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ [![](https://github.com/raw/libp2p/js-libp2p-interfaces/master/src/transport/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/transport) [![](https://github.com/raw/libp2p/js-libp2p-interfaces/master/src/connection/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/connection) -> JavaScript implementation of the TCP module for libp2p. It exposes the [interface-transport](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/transport) for dial/listen. `libp2p-tcp` is a very thin shim that adds support for dialing to a `multiaddr`. This small shim will enable libp2p to use other transports. +> JavaScript implementation of the TCP module for libp2p. It exposes the [interface-transport](https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/libp2p-interfaces/src/transport) for dial/listen. `libp2p-tcp` is a very thin shim that adds support for dialing to a `multiaddr`. This small shim will enable libp2p to use other transports. ## Table of Contents @@ -39,8 +39,8 @@ ```js import { TCP } from '@libp2p/tcp' -import { Multiaddr } from '@multiformats/multiaddr' -import pipe from 'it-pipe' +import { multiaddr } from '@multiformats/multiaddr' +import {pipe} from 'it-pipe' import all from 'it-all' // A simple upgrader that just returns the MultiaddrConnection @@ -51,12 +51,14 @@ const upgrader = { const tcp = new TCP({ upgrader }) -const listener = tcp.createListener({}, (socket) => { - console.log('new connection opened') - pipe( - ['hello'], - socket - ) +const listener = tcp.createListener({ + handler: (socket) => { + console.log('new connection opened') + pipe( + ['hello', ' ', 'World!'], + socket + ) + } }) const addr = multiaddr('/ip4/127.0.0.1/tcp/9090') @@ -79,14 +81,14 @@ Outputs: ```sh listening new connection opened -Value: hello +Value: hello World! ``` ## API ### Transport -[![](https://github.com/raw/libp2p/js-libp2p-interfaces/master/src/transport/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/transport) +[![](https://github.com/raw/libp2p/js-libp2p-interfaces/master/packages/libp2p-interfaces/src/transport/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/libp2p-interfaces/src/transport) `libp2p-tcp` accepts TCP addresses as both IPFS and non IPFS encapsulated addresses, i.e: @@ -97,7 +99,7 @@ Value: hello ### Connection -[![](https://github.com/raw/libp2p/js-libp2p-interfaces/master/src/connection/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/connection) +[![](https://github.com/raw/libp2p/js-libp2p-interfaces/master/packages/libp2p-interfaces/src/connection/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/libp2p-interfaces/src/connection) ## Contribute