Events/PubSub via WebSockets
JavaScript CoffeeScript Perl
Switch branches/tags
Nothing to show
Latest commit 2d9d902 Apr 12, 2013 @contra contra Merge pull request #4 from ranweiler/master
Adjust to changes in mocha API
Permalink
Failed to load latest commit information.
dist rebuild Feb 22, 2013
example test fix Feb 25, 2013
lib Close GH-3: Call ready and close callbacks only once. Feb 22, 2013
test Update testing config for mocha >= 1.9 Apr 11, 2013
.gitignore .gitignore Feb 4, 2013
.npmignore .gitignore Feb 4, 2013
.travis.yml fix for multiple clients Aug 18, 2012
LICENSE first version Jul 1, 2012
Makefile fix demo Feb 11, 2013
README.md update docs Nov 26, 2012
component.json bump Feb 25, 2013
index.js first version Jul 1, 2012
package.json Update testing config for mocha >= 1.9 Apr 11, 2013
pulsar.js test fix Feb 25, 2013
pulsar.min.js test fix Feb 25, 2013

README.md

status

Information

Package pulsar
Description Events + PubSub via WebSockets
Node Version >= 0.6

Pulsar uses ES5 features so be sure to include es5shim on your page.

Example

Server

var Pulsar = require('pulsar');
var server = http.createServer().listen(8080);
var pulse = Pulsar.createServer(server);

channel = pulse.channel('test');
channel.on('ping', function (num) {
  channel.emit('pong', num);
});

Client

var pulse = Pulsar.createClient();
channel = pulse.channel('test');
channel.emit('ping', 2);
channel.on('pong', function(num){
  // num === 2
});

Server Usage

Create

-- Options --
resource - change to allow multiple servers on one port (default: "default")
var Pulsar = require('pulsar');
var pulse = Pulsar.createServer(httpServer, {options});

Client Usage

Create

-- Options --
host - server location (default: window.location.hostname)
port - server port (default: window.location.port)
secure - use SSL (default: window.location.protocol)
resource - change to allow multiple servers on one port (default: "default")
var pulse = Pulsar.createClient({options});

Middleware

Middleware can be added to intercept or cancel inbound events. Syntax is the same on the client and server.

channel.use(function(emit, event, args...){
  if (event === 'login') {
    emit(); // Send the event on its way, emit with the same args
  } else {
    emit(1, 2, 3); // Send the event on its way, emit with new args
  }
  // Don't call emit and the event will be cancelled
});

LICENSE

(MIT License)

Copyright (c) 2012 Fractal contact@wearefractal.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.