npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@0xvaibhav/ipfs-messenger

v1.0.9

Published

IPFS helper packager for communication between two ipfs peers using ipfs-pubsub. Ideal for server-to-server communication.

Downloads

4

Readme

ipfs-messenger

1-1 messaging for ipfs nodes. Emits connection events, listening for messages, send messages to nodes. Best suited for server-to-server messaging.

Install

npm install @0xvaibhav/ipfs-messenger

Use

Initializing and starting the messenger.

import * as IPFS from "ipfs-core";
import Messenger from "@0xvaibhav/ipfs-messenger";
const ipfs = await IPFS.create();
const messenger = new Messenger(ipfs, {});
await messenger.start();

Listen for events emitted when starting messenger.

messenger.on("start", (m) => {
    console.log(m.message)
})

Once messenger has been started, listen to incoming messages.

messenger.on("message", (m) => {
    console.log(m.data)
});

Make sure to establish connection with other node before sending any message and only on establishment of connection, proceed to send any message.

messenger.on("connected", (d) => {
    console.log(`Connected to ${d.address}`)
    messenger.send("to-address", "Any Message (Objects should be stringyfied)")
})
messenger.connect("ipfs-address")

Close connection and stop listening for messages.

messenger.on("disconnected", (d) => {
    console.log(`Disconnected from ${d.address}`)
})
messenger.on("stop", () => {
    console.log("Stopped listening to any incoming messages")
})
messenger.disconnect("ipfs-address")
messenger.stop()

Find more in the examples directory.

API

new Messenger(ipfs, {options})

  • ipfs : IPFS Node, Must have pubsub activated.
    const messenger = new Messenger(ipfs, {})

messenger.start()

Starts the messenger

messenger.stop()

Stops the messenger

messenger.connect(ipfsAddr: string)

  • ipfsAddr: string, Address of IPFS node to connect with. Establish connection to IPFS node. Required before sending any message.

messenger.disconnect(ipfsAddr)

Terminate the connection established with an IPFS node.

messenger.send(ipfsAddr: string, message: string)

  • message: string, Data to be sent across. Send message to the IPFS node with which connection has already been established.

messenger.events.on("start", ({message}) => console.log(message))

Once the messenger has been started.

messenger.events.on("stop", ({message}) => console.log(message))

Once the messenger has been stopped.

messenger.events.on("connected", ({address}) => console.log(address))

When connected with an IPFS node.

messenger.events.on("disconnected", ({address}) => console.log(address))

When disconnect with an IPFS node.

messenger.events.on("message", ({data}) => console.log(data))

When a message is received.

messenger.events.on("sent", ({data}) => console.log(data))

Once a message has been successfully sent.

Contribute

Feel free to join in. All welcome. Open an issue!