   handleSocketEvent: (event, payload, autoConnect = true) ->
     isIP = event is 'ip' and IP.isIP payload
     ip = if isIP then payload else @legacyToIp event, payload
+    return unless ip
 
     if not @isConnected() and autoConnect and @brackets.length is 0
       # Connect before sending


    # Wrap legacy events into appropriate IP objects
    switch event
      when 'connect', 'begingroup'
        return new IP 'openBracket', payload
      when 'disconnect', 'endgroup'
        return new IP 'closeBracket'
      else
        return new IP 'data', payload

  ipToLegacy: (ip) ->
    switch ip.type

  #         @readBuffer fd, position, size, buffer
  connect: ->
    @connected = true
    @emitEvent 'connect', null

  disconnect: ->
    @connected = false
    @emitEvent 'disconnect', null

  isConnected: -> @connected

