diff --git a/client/client.js b/client/client.js
index 225b63c..8c71852 100755
--- a/client/client.js
+++ b/client/client.js
@@ -7,7 +7,8 @@ var socket
, preventRefresh = false
, fixwrap
, SERVER_EVENTS = ['init', 'join', 'leave', 'rejoin', 'taken', 'setHash', 'remaining', 'puzzled',
- 'add', 'hint', 'start', 'win', 'msg'];
+ 'add', 'hint', 'start', 'win', 'msg', 'disconnect', 'reconnect', 'reconnecting',
+ 'reconnect_failed'];
$(function() {
fixwrap = $('#fixwrap');
@@ -17,10 +18,8 @@ $(function() {
});
function startGame() {
- socket = io.connect(null, {
- rememberTransport: true
- , transports: ['websocket', 'flashsocket', 'xhr-multipart', 'xhr-polling', 'jsonp-polling']
- });
+ socket = io.connect();
+
socket.on('connect', function() {
$('#announcement').html('
Connected!
');
$('#announcement').removeClass('loading');
@@ -34,11 +33,6 @@ function startGame() {
SERVER_EVENTS.forEach(function(event) {
socket.on(event, window[event]);
});
-
- socket.on('disconnect', socket_disconnect);
- socket.on('reconnect', socket_reconnect);
- socket.on('reconnecting', socket_reconnect);
- socket.on('reconnect_failed', socket_reconnect_failed);
$('#hint').click(requestHint);
$('#input').keydown(input);
@@ -430,15 +424,15 @@ function initGame() {
socket.emit('init', init);
}
-function socket_disconnect() {
+function disconnect() {
msg({event:true, msg: 'You have been disconnected'})
}
-function socket_reconnect() {
+function reconnect() {
msg({event:true, msg: 'Reconnected to server'})
}
-function socket_reconnecting(nextRetry) {
+function reconnecting(nextRetry) {
msg({event:true, msg: ('Attempting to re-connect to the server, next attempt in ' + nextRetry + 'ms')})
}
-function socket_reconnect_failed() {
+function reconnect_failed() {
msg({event:true, msg: 'Reconnect to server FAILED.'})
}
diff --git a/server.js b/server.js
index 5f94232..44407c9 100644
--- a/server.js
+++ b/server.js
@@ -11,7 +11,8 @@ var http = require('http')
, latestPublicGame
, clientDir = __dirname + '/client'
, publicDir = __dirname + '/public'
- , depsDir = __dirname + '/deps';
+ , depsDir = __dirname + '/deps'
+ , prod = process.env.NODE_ENV === 'production';
buildStaticFiles();
@@ -44,21 +45,29 @@ server = connect.createServer(
, niceifyURL
, gzip.staticGzip(publicDir, {
matchType: /text|javascript/
- , maxAge: process.env.NODE_ENV === 'production' ? 86400000 : 0
+ , maxAge: prod ? 86400000 : 0
})
, gzip.staticGzip(publicDir + '/perm', {
matchType: /image|font/
- , maxAge: process.env.NODE_ENV === 'production' ? 604800000 : 0
+ , maxAge: prod ? 604800000 : 0
})
);
-server.listen(process.env.NODE_ENV === 'production' ? 80 : 8000);
+server.listen(prod ? 80 : 8000);
io = io.listen(server);
io.configure('production', function() {
io.enable('browser client minification'); // send minified client
io.enable('browser client etag'); // apply etag caching logic based on version number
io.enable('browser client gzip'); // gzip the file
+ io.set('log level', 1); // reduce logging
+ io.set('transports', [ // enable all transports (optional if you want flashsocket)
+ 'websocket'
+ , 'flashsocket'
+ , 'htmlfile'
+ , 'xhr-polling'
+ , 'jsonp-polling'
+ ]);
});
function getUnusedHash() {
@@ -115,6 +124,7 @@ function randString(size) {
function buildStaticFiles() {
var options = {
+ uglifyjs: prod,
jstransport: false,
cssabspath: false,
csshost: false,