Permalink
Browse files

Adding em-websocket to dependencies, ability to change websocket port

  • Loading branch information...
1 parent 1927e46 commit 40391c412c7fcbbdc6166c0a387d1f319da79a26 @winton committed Mar 15, 2011
Showing with 10 additions and 2 deletions.
  1. +1 −0 config/gemsets.yml
  2. +1 −0 config/gemspec.yml
  3. +8 −2 public/puggernaut.js
View
@@ -1,4 +1,5 @@
puggernaut:
+ em-websocket: ~>0.2.1
eventmachine: ~>0.12.10
rake: >=0.8.7
rspec: ~>1.0
View
@@ -7,5 +7,6 @@ homepage: http://github.com/winton/puggernaut
summary: Simple server push implementation using eventmachine and long polling
description: Simple server push implementation using eventmachine and long polling
dependencies:
+ - em-websocket
- eventmachine
development_dependencies: null
View
@@ -10,7 +10,7 @@ var Puggernaut = new function() {
this.watch = watch;
this.watch_join = watch_join;
this.watch_leave = watch_leave;
- this.websockets_port = 8102;
+ this.webSocketPort = webSocketPort;
var channels = {};
var errors = 0;
@@ -19,6 +19,7 @@ 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) {
@@ -189,7 +190,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 + ":" + this.websockets_port + "/");
+ request = new WebSocket("ws://" + window.location.host + ":" + webSocketPort() + "/");
request.onopen = function() {
errors = 0;
if (started)
@@ -215,4 +216,9 @@ var Puggernaut = new function() {
};
}
}
+
+ function webSocketPort(p) {
+ if (p) port = p;
+ return port;
+ }
};

0 comments on commit 40391c4

Please sign in to comment.