aboutsummaryrefslogtreecommitdiff
path: root/webcastor.js
diff options
context:
space:
mode:
Diffstat (limited to 'webcastor.js')
-rw-r--r--webcastor.js18
1 files changed, 6 insertions, 12 deletions
diff --git a/webcastor.js b/webcastor.js
index b652854..deff3bf 100644
--- a/webcastor.js
+++ b/webcastor.js
@@ -25,7 +25,6 @@ var imports = {
25 hogan : require('hogan-express'), 25 hogan : require('hogan-express'),
26 26
27 socketio : require('socket.io'), 27 socketio : require('socket.io'),
28 socketioWildcard : require('socket.io-wildcard'),
29 28
30 redis : require('redis'), 29 redis : require('redis'),
31 30
@@ -34,8 +33,7 @@ var imports = {
34 33
35var params = { 34var params = {
36 database : { 35 database : {
37 persistent : process.env.REDISCLOUD_URL !== undefined 36 persistent : process.env.REDISCLOUD_URL !== undefined && process.env.REDISCLOUD_URL !== null,
38 && process.env.REDISCLOUD_URL !== null,
39 server : process.env.REDISCLOUD_URL, 37 server : process.env.REDISCLOUD_URL,
40 }, 38 },
41 39
@@ -106,8 +104,7 @@ var Server = {
106 104
107 this.app = this.createApp(); 105 this.app = this.createApp();
108 this.server = imports.http.createServer(this.app); 106 this.server = imports.http.createServer(this.app);
109 this.io = imports.socketioWildcard(imports.socketio) 107 this.io = imports.socketio.listen(this.server);
110 .listen(this.server);
111 108
112 this.addHandlers(this.app, this.io); 109 this.addHandlers(this.app, this.io);
113 110
@@ -183,15 +180,14 @@ var Server = {
183 180
184 socket.join(channel); 181 socket.join(channel);
185 182
186 if (!imports.passwordHash.verify(password, hashedPassword) 183 if (!imports.passwordHash.verify(password, hashedPassword) && hashedPassword !== 'none') {
187 && hashedPassword !== 'none') {
188 console.log('Client joined ' + channel); 184 console.log('Client joined ' + channel);
189 return; 185 return;
190 } 186 }
191 187
192 console.log('Broadcaster joined ' + channel); 188 console.log('Broadcaster joined ' + channel);
193 189
194 socket.on('*', function(event) { 190 socket.on('message', function(event) {
195 Server.broadcast(socket, channel, event); 191 Server.broadcast(socket, channel, event);
196 }); 192 });
197 }); 193 });
@@ -202,13 +198,11 @@ var Server = {
202 198
203 var messageSize = encodeURI(JSONmessage).split(/%..|./).length - 1; 199 var messageSize = encodeURI(JSONmessage).split(/%..|./).length - 1;
204 if (messageSize > params.messageSizeLimit) { 200 if (messageSize > params.messageSizeLimit) {
205 console.log('Not broadcasting ' + JSONmessage + ' (' + messageSize 201 console.log('Not broadcasting ' + JSONmessage + ' (' + messageSize + ' bytes)');
206 + ' bytes)');
207 return; 202 return;
208 } 203 }
209 204
210 console.log('Broadcasting ' + JSONmessage + ' (' + messageSize 205 console.log('Broadcasting ' + JSONmessage + ' (' + messageSize + ' bytes)');
211 + ' bytes)');
212 socket.broadcast.to(channel).emit(event.name, event.args); 206 socket.broadcast.to(channel).emit(event.name, event.args);
213 }, 207 },
214}; 208};