     res = new eslResponse socket
     socket.emit event, req, res
   # Get things started
-  @emit 'esl_connect', new eslResponse socket
+  @emit 'esl_connect', new eslResponse socket if @emit?
 
 class eslServer extends net.Server
   constructor: (requestListener) ->

      # Make sure we are the only one receiving command replies
      @socket.removeAllListeners('esl_command_reply')
      if cb?
        @on 'esl_command_reply', (req,res) ->
          cb(req,res)

      @socket.write "#{command}\n"

exports.createServer = (requestListener) -> return new eslServer(requestListener)

class eslClient extends net.Socket
  constructor: () ->
    @on 'connect', () -> connectionListener(this)
    super()

exports.createClient = () -> return new eslClient()


# Examples:
###

client =  createClient()
client.on 'esl_auth_request', (req,res) ->
    res.auth "ClueCon", () ->
      res.send 'event json HEARTBEAT'
client.connect(8021, '127.0.0.1')
###

