-RTCConnection = (leagueId) ->
+activeSessions = {}
+
+RTCConnection = (leagueId, element) ->
   connection = new RTCMultiConnection(leagueId)
   onMessageCallbacks = {}
   socket = io.connect('http://localhost:5555/')

  socket.on 'message', (data) ->
    return if data.sender == connection.userid
    frameId = data.message?.sessionid
    extra = connection.sessionDescriptions[frameId]?.extra
    extra.lastMessage = new Date() if extra

    if onMessageCallbacks[data.channel]
      onMessageCallbacks[data.channel](data.message)

    leagueId: String
  },
  ready: ->
    connection = RTCConnection(this.leagueId, @)
    connection.onNewSession = (e) ->
    setInterval(clearOldSessions.bind(@, connection), 10000)
