Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Simple server push implementation using eventmachine and long polling
JavaScript Ruby
tree: 40afdadce2

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
config
lib
spec
.gitignore
LICENSE
README.md
Rakefile
puggernaut.gemspec
puggernaut.png

README.md

Puggernaut

Simple server push implementation using eventmachine and long polling.

Puggernaut

Requirements

gem install puggernaut

How it works

Puggernaut consists of three pieces:

  • TCP client to send push messages
  • TCP server to receive push messages
  • HTTP server to deliver long poll requests

Start it up

Run the puggernaut binary with optional port numbers:

puggernaut <http port> <tcp port>

The default HTTP and TCP ports are 8000 and 8001, respectively.

Send push messages

require 'puggernaut'

client = Puggernaut::Client.new("localhost:8001", "localhost:9001")
client.push :channel => "message"
client.push :channel => [ "message 1", "message 2" ], :channel_2 => "message"

The Client.new initializer accepts any number of TCP server addresses.

Set up proxy pass

You will need to set up a URL on your public facing web server that points to the Puggernaut HTTP server.

If you do not see your web server below, Google is your friend.

Apache

http.conf

ProxyPass /long_poll http://localhost:8000
ProxyPassReverse /long_poll http://localhost:8000

Nginx

nginx.conf

location /long_poll {
  proxy_pass http://localhost:8000
}

Receive push messages

Include puggernaut.js into to your HTML page.

Javascript client example:

Puggernaut('/long_poll')
  .watch('channel', function(message) {
    // do something with message
  })
  .watch('channel_2', function(message) {
    // do something with message
  });
Something went wrong with that request. Please try again.