@libp2p/echo
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

@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.

Example

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']
  },
  connectionEncryption: [noise()],
  streamMuxers: [yamux()],
  services: {
    echo: echo()
  }
})

const sender = await createLibp2p({
  addresses: {
    listen: ['/ip4/0.0.0.0/tcp/0']
  },
  connectionEncryption: [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

Browser <script> tag

Loading this module through a script tag will make it's 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.

Readme

Keywords

none

Package Sidebar

Install

npm i @libp2p/echo

Weekly Downloads

600

Version

1.0.7

License

Apache-2.0 OR MIT

Unpacked Size

22.1 kB

Total Files

20

Last publish

Collaborators

  • jacobheun
  • npm-service-account-libp2p
  • alanshaw
  • vascosantos
  • achingbrain
  • daviddias