 sqlite3 = require('sqlite3')
 util = require('util')
 _ = require('underscore')
+
+logError = (err) ->
+    util.log(err.stack)
+
+process.on('uncaughtException', logError)
 
 class Player
     constructor: (socket, request) ->

            GlobalLobby.removeByID(player.id)
            cb(players)
        )
    ))
    socket.on('sendChat', handleErrors((text) ->
        if GlobalLobby.isPresent(socket.id)
            GlobalLobby.sendChat(socket.id, text)
        else
            LobbyManager.sendChat(socket.id, text)
    ))
    socket.on('exitLobby', handleErrors(->
        LobbyManager.removePlayer(socket.id)
    ))
    socket.on('disconnect', handleErrors(->
        GlobalLobby.removeByID(socket.id)
        LobbyManager.removePlayer(socket.id)
    ))
)

        return unless id of @lobbies_by_id
        @lobbies_by_id[id].sendChat(id, text)
LobbyManager = new LobbyManagerGlobal()
setInterval(LobbyManager.matchmake, 5000)

class GlobalLobbyGlobal
    constructor: ->
