var Runner = require('./runner').Runner;

module.exports = function (ws) {

    /*var id = setInterval(function() {
        ws.send(JSON.stringify(process.memoryUsage()), function() { });
    }, 1000);
    console.log('started client interval');*/

    ws.on('message', function(message) {
        var data = JSON.parse(message);
        var runner = new Runner(data.commands);
        runner.runGame(function() {
            ws.send(runner.gameResult, function() { /* No error handling yet */ });
        });
    });

    ws.on('close', function() {
        console.log('Closing WS connection');
    });

};
var Runner = require('./runner').Runner;

module.exports = function (ws) {

    /*var id = setInterval(function() {
        ws.send(JSON.stringify(process.memoryUsage()), function() { });
    }, 1000);
    console.log('started client interval');*/

    ws.on('message', function(message) {
        var data = JSON.parse(message);
        var runner = new Runner(data.commands);
        runner.runGame(function() {
            ws.send(runner.gameResult.log + runner.gameResult.result, function() { /* No error handling yet */ });
        });
    });

    ws.on('close', function() {
        console.log('Closing WS connection');
    });

};
Fix server program to show game result.