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

peero-server

v2.2.0

Published

Websocket server which facilitates discovery between Peero client peers.

Downloads

7

Readme

WebSocket server which facilitates discovery between Peero client peers.

What & why

WebRTC peers are unable to connect to each other without exchanging connection data (IP adresses, etc). The way this exchange is performed is not a part of the WebRTC spec, so it's up to the developer to come up with a way to do this. There are already signaling servers which do exactly this, but Peero server is just a different type of implementation that's supposed to be simple and open source.

The only thing the server does is keep a list of online peers, and passes SDP data from one peer to another to make those peers connect. All communication between peers is strictly peer-to-peer. There is also an implementation of a Peero client, which connects to the server and available peers.

Installation

To run the server, you will need to have Node.js and npm installed, so you can:

$ npm install peero-server

Usage

const PeeroServer = require('peero-server')

const server = new PeeroServer({
    port: '80'
})

server.run((port) => {
    console.log('Running on port: ' + port)
})

Options

The constructor accepts the following options:

  • port: The port of the WebSocket server. Default: 8080.

Methods

  • run(callback): Initializes the server. The callback returns the port which has been set in the options.
  • close(callback): Closes the server and exits the process.

Events

The instance emits the following events:

  • on('connection', (socket)): When a client establishes a connection with the server.
  • on('message', (socket, message)): When any WebSocket message is sent to a client.
  • on('offer', (socket, signal)): When an 'offer' signal is sent to all connected clients (except the signaling client).
  • on('answer', (socket, peerId, signal)): When an 'answer' signal is sent to a client. peerId is the ID of the answering client.
  • on('announce', (socket)): When connected clients have been notified of a new connected client.
  • on('peers', (socket, peers)): When the list of connected clients have been sent to a client.
  • on('remove', (peerId)): When a client has been removed from the list of connected clients (due to connectivity issues, for example).
  • on('error', (err, socket)): When a message fails to reach a client (due to connectivity issues, for example). The client is also automatically removed from the list of connected clients when this occurs.