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

wave

v0.2.3

Published

Wave Gadget API implementation

Downloads

171

Readme

Wave-Node

This is an implementation of the Google Wave Gadget API using Node.js, Socket.io, and Redis.

It uses diff-match-patch to synchronize states across multiple instances: clients send patches to the server, which then propagates the patches to other clients which apply the patches to their local state model. So no matter how big the state model becomes, each update event is quite small.

Installation

Install Wave using NPM with:

$ npm install wave

Creating a Wave server

To create a Wave server instance, attach it to a http server instance as follows:

var server = http.createServer(function(req, res){ 
  res.writeHead(200, {'Content-Type': 'text/html'}); 
  res.end('<h1>Wave Gadget API Server</h1>');   
});
var wave = require('wave').Server;
wave.attach(server);
server.listen(8000, "127.0.0.1");

Note that you must have Redis running.

Setting Redis options

You can set various options for redis by passing a map of options to the attach() method, e.g.:

wave.attach(server, {"host":"127.0.0.1", "port":"6379", "clear":true});

The "clear" option, when set true, clears out all existing states. Other valid options are "host", "port", and any standard Redis configuration options you can pass to node_redis using redis.createClient(). See node-redis for more information.

Running the examples

To run the examples, you need to start your Redis server, and start a new Wave server using:

$ node examples/server/server.js

You can then run the examples by opening examples/index.htm in a browser and following the instructions on the page.

Client API

Each page or widget wanting to use the service needs to import the following JavaScript files:

diff_match_patch.js
json2.js
socket.io.js
wave.js

These can all be found in the "client" folder; you can also load the current socket.io.js client from the server itself (e.g. http://localhost:8081/socket.io/socket.io.js)

In addition you need to call the following methods in your own scripts after importing the wave.js library:

wave.setSharedDataKey(key) : this is the "context identifier" for the pages/widgets that will share state.
wave.setViewer(id, name, icon src) : this is the current user's information

For example:

wave.setSharedDataKey("SPACE1");
wave.setViewer("mindyourownbusiness","alice","smileys/rabbit.png");

When both have been set, your page/widget will handshake with the server.

You can then use the Wave Gadget API as described at: http://code.google.com/apis/wave/extensions/gadgets/guide.html

Notes

Note that private states are not supported yet, nor are getHost() or state.clear().