Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

peero-server

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

peero-server

Websocket server which facilitates discovery between Peero client peers.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

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 & usage

To run the server, you will need to have Node installed. The code is not available on npm, so you will have to pull/download it from Github. And then in command line:

> cd peero-server
> # install pm2 globally if it isn't installed already
> npm install pm2 -g
> pm2 pm2.config.js

A client can connect with the server on ws://localhost:8080. You can read the PM2 documentation on how to work with the process manager.

You can copy .env.example to a new .env file to set some environment settings, for example:

NODE_ENV=production
WS_PORT=8000

How it works

The server works only with websocket requests. All messages passed from and to the server are serialized JSON/Javascript objects. For a client to connect to the server it needs to send a 'register' message:

{
    type: 'register'
}

When the server receives that message, it will generate a UUIDv4 ID and send it to the client:

{
    type: 'register',
    data: { peerId: 'af988091-4454...' }
}

The server will simultaneously send messages to other connected clients to announce a new client:

{
    type: 'announce',
    data: { peerId: 'af988091-4454...' }
}

It will also send all currently connected clients to the new client:

{
    type: 'peers',
    data: {
        peers: [
            '6f01ab34-3a56...',
            '72a4ad27-bde5...'
        ]
    }
}

Keywords

FAQs

Package last updated on 10 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc