       if !client? || !_.contains(client.installedMods, mod.name+"="+mod.version)
         throw new Meteor.Error 401, mod.name
     return createLobby(@userId, mod, name)
+  "joinBroadcaster": (slot)->
+    return if !@userId?
+    lobby = findUserLobby(@userId)
+    return if !lobby?
+    if !lobby.spectatorEnabled
+      throw new Meteor.Error 503, "Spectators are not enabled in this lobby."
+    if slot >= lobby.spectator.length
+      throw new Meteor.Error 503, "That spectator slot doesn't exist."
+    setPlayerTeam lobby, @userId, "spectator"+slot
   "switchTeam": (team)->
     return if !@userId?
     lobby = findUserLobby(@userId)

        log.info " -X- #{player.name}"
    lobbies.update {_id: id}, {$set: {status: 0, state: GAMESTATE.Init, radiant:lobby.radiant, dire:lobby.dire}}

setPlayerTeam = (lobby, uid, tteam)->
  return if !lobby?
  index = _.findWhere(lobby.radiant, {_id: uid})
  team = "radiant"
  if !index?
    index = _.findWhere(lobby.dire, {_id: uid})
    team = "dire"
  return if tteam is team
  if index?
    index = lobby[team].indexOf(index)
    lobby[tteam].push(lobby[team].splice(index, 1)[0])
    lobbies.update {_id: lobby._id},
      $set:
        radiant: lobby.radiant
        dire: lobby.dire

@checkIfDeleteLobby = (lobbyId)->
  lobby = lobbies.findOne({_id: lobbyId})

    creatorid: creatorId
    radiant: [{_id: creatorId, name: user.profile.name, avatar: user.services.steam.avatar, steam: user.services.steam.id}]
    dire: []
    spectator: [[], [], [], []]
    spectatorEnabled: AuthManager.userIsInRole creatorId, ["admin", "developer", "moderator"]
    isMatchmaking: false
    mod: mod.name
    serverIP: ""
    mmid: null
    public: true
