Skip to content
Browse files

README, better port accessor

  • Loading branch information...
1 parent 9116913 commit d0e22468538c9b1b73ac18b7bdbeaa07dd074d67 @winton committed Mar 15, 2011
Showing with 14 additions and 27 deletions.
  1. +12 −19 README.md
  2. +2 −8 public/puggernaut.js
View
31 README.md
@@ -15,46 +15,38 @@ gem install puggernaut
How it works
------------
-Puggernaut consists of three pieces:
+Puggernaut consists of four pieces:
* TCP client to send push messages
* TCP server to receive push messages
-* HTTP server to deliver long poll requests
+* TCP server to deliver messages via WebSockets ([em-websocket](https://github.com/igrigorik/em-websocket))
+* HTTP server to deliver messages via long poll
Start it up
-----------
Run the <code>puggernaut</code> binary with optional port numbers:
<pre>
-puggernaut &lt;http port&gt; &lt;tcp port&gt;
+puggernaut &lt;http port&gt; &lt;tcp port&gt; &lt;tcp port (websocket)&gt;
</pre>
-The default HTTP and TCP ports are 8100 and 8101, respectively.
+The default HTTP and TCP ports are 8100, 8101, and 8102, respectively.
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](http://google.com) is your friend.
-
-### Apache
-
-*http.conf*
-
-<pre>
-ProxyPass /long_poll http://localhost:8100/
-ProxyPassReverse /long_poll http://localhost:8100/
-</pre>
-
-### Nginx
+We all use Nginx, right?
*nginx.conf*
<pre>
-location /long_poll {
- proxy_pass http://localhost:8100/;
+server {
+ location /long_poll {
+ proxy_pass http://localhost:8100/;
+ }
}
</pre>
@@ -79,7 +71,8 @@ Include [jQuery](http://jquery.com) and [puggernaut.js](https://github.com/winto
Javascript client example:
<pre>
-Puggernaut.path = '/long_poll'; // (default)
+Puggernaut.path = '/long_poll'; // (default long poll path)
+Puggernaut.port = 8102; // (default WebSocket port)
Puggernaut
.watch('channel', function(e, message) {
View
10 public/puggernaut.js
@@ -5,12 +5,12 @@ var Puggernaut = new function() {
this.disabled = false;
this.path = '/long_poll';
+ this.port = 8102;
this.inhabitants = inhabitants;
this.unwatch = unwatch;
this.watch = watch;
this.watch_join = watch_join;
this.watch_leave = watch_leave;
- this.webSocketPort = webSocketPort;
var channels = {};
var errors = 0;
@@ -19,7 +19,6 @@ var Puggernaut = new function() {
var started = false;
var request;
var request_id;
- var port = 8102;
function ajax(join_leave, time, user_id) {
if (channelLength() > 0 && !self.disabled && errors <= 10) {
@@ -190,7 +189,7 @@ var Puggernaut = new function() {
function websocket(join_leave, time, user_id) {
if (channelLength() > 0 && !self.disabled && errors <= 10) {
started = true;
- request = new WebSocket("ws://" + window.location.host + ":" + webSocketPort() + "/");
+ request = new WebSocket("ws://" + window.location.host + ":" + self.port + "/");
request.onopen = function() {
errors = 0;
if (started)
@@ -216,9 +215,4 @@ var Puggernaut = new function() {
};
}
}
-
- function webSocketPort(p) {
- if (p) port = p;
- return port;
- }
};

0 comments on commit d0e2246

Please sign in to comment.
Something went wrong with that request. Please try again.