       when "leave"
         removePlayer(socket, socket.request.user.username)
         socket.leave(msg.gameid)
-        lobby.emit('netrunner', {type: "games", games: games})
 
       when "quit"
         removePlayer(socket, socket.request.user.username, "quit")


  socket.on 'disconnect', () ->
    removePlayer(socket, socket.request.user.username, "disconnect") if socket.request.user
    lobby.emit('netrunner', {type: "games", games: games})

  socket.on 'netrunner', (msg) ->
    switch msg.action

            lobby.to(game.gameid).emit("netrunner", {type: "state", state: state})
          else
            socket.to(game.gameid).emit('netrunner', {type: "say", user: "__system__", text: "#{username} left the game."})
    if game.players.length is 0
      games.splice(i, 1)
  lobby.emit('netrunner', {type: "games", games: games})

# Socket.io
io.use (socket, next) ->
