   #         @readBuffer fd, position, size, buffer
   connect: ->
     @connected = true
-    @handleSocketEvent 'connect', null, false
+    @emitEvent 'connect', null
 
   disconnect: ->
     @connected = false
-    @handleSocketEvent 'disconnect', null, false
+    @emitEvent 'disconnect', null
 
   isConnected: -> @connected
 


    # 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

  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
