   ipToLegacy: (ip) ->
     switch ip.type
       when 'openBracket'
-        @braceCount++
-        if @braceCount is 1
+        if @brackets.length is 1
           return legacy =
             event: 'connect'
             payload: @

          event: 'data'
          payload: ip.data
      when 'closeBracket'
        @braceCount--
        if @braceCount is 0
          return legacy =
            event: 'disconnect'
            payload: @

        metadata: @metadata

  constructor: (@metadata = {}) ->
    @brackets = []
    @dataDelegate = null
    @debug = false
    @emitEvent = @regularEmitEvent

  # ## Socket connections
  #
