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

auto-peer

v0.8.1

Published

Automatic peer connection

Downloads

7

Readme

auto-peer.js Build Status Dependency Status Built with Grunt

Abstract

auto-peer.js automates the peer.js connection establishment and connects all auto-peer.js clients with each other using webRTC.

The auto-peer.js library is an experimental webRTC client/server library which relies heavily on peerjs

Motivation

The idea auto-peer.js was developed when creating a multi media installation for a couple of tablets. It should allow to communicate from tablet to tablet as fast as possible.

http://engineering.spilgames.com/mastering-webrtc/ from http://engineering.spilgames.com/mastering-webrtc/

How does it work?

tl;dr: WebRTC with a node signaling server

auto-peer.js core consists of a node websocket backend and a client side script. When the user opens the application a new client is created. This client asks the backend to tell all existing clients to establish a new webRTC connection.

Demos

http://runnable.com/favicon.ico Drag'n'Drop

http://runnable.com/favicon.ico Ping

Example

Take a look at the example directory.

Server

var app = require('express')();
var server = app.listen(3000);
var autoPeer = require('auto-peer')(server);

app.use(autoPeer.app);

app.get('/', function (req, res) {
  res.sendFile(__dirname + '/index.html');
});

Client

<!-- The auto-peer server delivers the client script at /auto-peer.min.js -->
<script src="/auto-peer.min.js"></script>
<script>
    var autoPeer = new AutoPeer();
    // Wait until autoPeer connected
    autoPeer.on('autoPeer:connected', function (clientId) {
      autoPeer.broadcast('example-message', 'This is a message to all connected peers from ' + clientId);
    });

    // Wait for incoming messages
    autoPeer.on('example-message', function (message, data) {
      console.log('received data:', message);
      // Reply kindly
      if (message !== 'thank you') {
        autoPeer.sendTo(data.source, 'example-message', 'thank you');
      }
    });
</script>

Api

autoPeer.broadcast(messageName, data, sendToSelf);
  • messageName - name of the message
  • data - optional data
  • sendToSelf - optional (only for client version) send message also to the current peer
autoPeer.sendTo(clientId, messageName, data);
  • clientId - the peer id the message should be send to
  • messageName - name of the message
  • data - optional data

Events

auto-peer inherits from eventEmitter3. for API methods see the official Node.js documentation: http://nodejs.org/api/events.html

Client

autoPeer:connected

Fired when the current peer is connected to every other peer

autoPeer:data

Fired when the current peer receives any data

autoPeer:peerJoined

Fired when another peer joined

Server

autoPeer:newClient

Fired when a new client connected to the server

Security

auto-peer.js is an experimental library and was not meant to be used in productive environment. As a client is able to send commands to any other client you should never evaluate html or javascript code transmitted by auto-peer.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

License

Copyright (c) 2014 Jan Nicklas. Licensed under the MIT license.