 
         connection.on 'message', _.bind @message, @, connection
 
-    disconnect: (cn, roomId, clientId)->
+    disconnect: (cn, clientId)->
         cn.on 'close', =>
-            delete @rooms[roomId][clientId]
-            delete @rooms[roomId] if _.isEmpty @rooms[roomId]
+            delete @connections[clientId]
 
     message: (cn, data)->
         mes = null


        if mes.host is 'tunnel'
            switch mes.pathname
                when '/connect_room' then @connectRoom cn, mes.query

        else
            @tunnelMessage cn, mes, data

    connectRoom: (cn, q)->
        roomId   = q.room   or @getUID 'r'
        clientId = q.client or @getUID 'c'

        @rooms[roomId] = {} unless @rooms[roomId]
        @rooms[roomId][clientId] = cn

        clearTimeout cn._startTO
        @disconnect cn, roomId, clientId
        @response cn, null, 'tunnel', '/created', room: roomId, client: clientId

    tunnelMessage: (cn, mes, data)->
        return if not mes.host or not @rooms[mes.host] or not @rooms[mes.host][mes.auth]
        room = @rooms[mes.host]
        currentClient = mes.auth

        for client of room
            unless client is currentClient
                room[client].send data

    response: (cn, c, h, m, q)->
        return unless h

        host: '0.0.0.0'
        timeout: 2000

    connections: {}

    constructor: (options) ->
        @options = _.extend {}, @options, options
