libp2p
    Preparing search index...

    Module @libp2p/echo

    An implementation of a simple Echo protocol.

    Any data received by the receiver will be sent back to the sender.

    import { noise } from '@chainsafe/libp2p-noise'
    import { yamux } from '@chainsafe/libp2p-yamux'
    import { echo } from '@libp2p/echo'
    import { peerIdFromString } from '@libp2p/peer-id'
    import { createLibp2p } from 'libp2p'

    const receiver = await createLibp2p({
    addresses: {
    listen: ['/ip4/0.0.0.0/tcp/0']
    },
    connectionEncrypters: [noise()],
    streamMuxers: [yamux()],
    services: {
    echo: echo()
    }
    })

    const sender = await createLibp2p({
    addresses: {
    listen: ['/ip4/0.0.0.0/tcp/0']
    },
    connectionEncrypters: [noise()],
    streamMuxers: [yamux()],
    services: {
    echo: echo()
    }
    })

    const stream = await sender.dialProtocol(receiver.getMultiaddrs(), sender.services.echo.protocol)

    // write/read stream

    @libp2p/echo

    libp2p.io Discuss codecov CI

    Implementation of an Echo protocol

    About

    An implementation of a simple Echo protocol.

    Any data received by the receiver will be sent back to the sender.

    import { noise } from '@chainsafe/libp2p-noise'
    import { yamux } from '@chainsafe/libp2p-yamux'
    import { echo } from '@libp2p/echo'
    import { peerIdFromString } from '@libp2p/peer-id'
    import { createLibp2p } from 'libp2p'

    const receiver = await createLibp2p({
    addresses: {
    listen: ['/ip4/0.0.0.0/tcp/0']
    },
    connectionEncrypters: [noise()],
    streamMuxers: [yamux()],
    services: {
    echo: echo()
    }
    })

    const sender = await createLibp2p({
    addresses: {
    listen: ['/ip4/0.0.0.0/tcp/0']
    },
    connectionEncrypters: [noise()],
    streamMuxers: [yamux()],
    services: {
    echo: echo()
    }
    })

    const stream = await sender.dialProtocol(receiver.getMultiaddrs(), sender.services.echo.protocol)

    // write/read stream

    Install

    $ npm i @libp2p/echo
    

    Loading this module through a script tag will make its exports available as Libp2pEcho in the global namespace.

    <script src="https://unpkg.com/@libp2p/echo/dist/index.min.js"></script>
    

    API Docs

    License

    Licensed under either of

    Contribution

    Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

    Interfaces

    Echo
    EchoComponents
    EchoInit

    Functions

    echo