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

reply_all

v1.0.0

Published

Add reply functionality to your network messages.

Downloads

17

Readme

Reply All

Reply All is a library that adds the ability to reply to messages sent using messaging protocols.

The reason I made this is I got tired of making variables and finding out where in my code the message was sent from. This helps with this issue by allowing me to add a callback to my message requests that is called when I call a reply function on the receiver side.

Supported Protocols:

  • TCP
  • UDP
  • Socket.IO (I made it for this not realizing it was already a feature)

TCP Example

In this example I send a message to the server and reply to the client, but this can be done either way.

Client

const net           = require('net');
const client        = new net.Socket();

//Import and init the library
const SocketReply   = require('../../index');
let sock            = new SocketReply(client, "tcp");

client.connect(3000, '127.0.0.1', function() {
    //This send a message to the server, notice the callback
    //That is called when (or if) the server replies
    //If the callback is not provided, the message is sent without reply functionality
    sock.write('Hello, server! Love, Client.', (data) => {
        console.log(data);
    });

    
    //No packet will be received if the message is a reply
    //Hoewever if you listen for packets the normal way, you will receive the reply which you dont want.
    //So make sure you only listen for packets using the libraries socket instance
    sock.on('data', (packet, reply) => {
        console.log(packet);
    });
});

//All other events must be listened to by the normal means
client.on('error', (err) => {
    console.log(err);
});

Server

const net               = require('net');
const SocketReply       = require('../../index');

const server = net.createServer(function(socket) {
    //This must be initialized for each socket
    let sock            = new SocketReply(socket, "tcp");

    sock.on('data', (packet, reply) => {
        console.log(packet);
        reply({success: true});
    });
    
    //All other events must be listened to by the normal means
    socket.on('error', function(err) {
    });
});

server.listen(3000, '127.0.0.1');

Check out the examples folder for other examples on how to use this library.