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.

  • 2.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
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

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.

Keywords

FAQs

Package last updated on 28 Aug 2019

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