module.exports = function Server(expressInstance, sessionStore) {
	var parseCookie = require('connect').utils.parseCookie;
	var io = require('socket.io').listen(expressInstance);

	io.configure(function () {
		io.set('log level', 0);
	});

	io.set('authorization', function(handshakeData, ack) {
		var cookies = parseCookie(handshakeData.headers.cookie);
		sessionStore.get(cookies['connect.sid'], function(err, sessionData) {
			handshakeData.session = sessionData || {};
			handshakeData.sid = cookies['connect.sid']|| null;
			ack(err, err ? false : true);
		});
	});

	io.sockets.on('connection', function(client) {
    client.emit('woo', 'Hello!');

		client.on('disconnect', function() { console.log('disconnect'); });

    client.on('scoreSubmit', function(scoreData) {
      console.log('Score submitted: ' + scoreData.score);
    });
	});

	io.sockets.on('error', function(){ console.log(arguments); });

	return io;
};

module.exports = function Server(expressInstance, sessionStore) {
var redis = require('redis'), redisClient = redis.createClient();
	var parseCookie = require('connect').utils.parseCookie;
	var io = require('socket.io').listen(expressInstance);

	io.configure(function () {
		io.set('log level', 0);
	});

	io.set('authorization', function(handshakeData, ack) {
		var cookies = parseCookie(handshakeData.headers.cookie);
		sessionStore.get(cookies['connect.sid'], function(err, sessionData) {
			handshakeData.session = sessionData || {};
			handshakeData.sid = cookies['connect.sid']|| null;
			ack(err, err ? false : true);
		});
	});

	io.sockets.on('connection', function(client) {
    client.emit('woo', 'Hello!');

		client.on('disconnect', function() { console.log('disconnect'); });

    client.on('scoreSubmit', function(scoreData) {
      // TODO - identify player
      redisClient.zadd('HIGHSCORES',scoreData.score, 'playername');
    });
	});

	io.sockets.on('error', function(){ console.log(arguments); });

	return io;
};

Store high scores to redis set