 class Cio
 
   constructor: (@_options) ->
+
+    # TODO:
+    #   check for error results from all of these.
+    #   set it on _error for the builder function to find and return
 
     @_clientChain = buildChain()
     @_serverChain = buildChain()

module.exports = (options) ->

  # if the certs are provided then try to read them now
  readCerts options if options?

  new Cio options


    if @_options?.noRelisten then @_serverChain.disable 'cio/relistener'

    return


  client: (options) ->
    result = @_run @_clientChain, options
    if result?.failed? then result
    else result?.context?.client

  server: (options) ->
    result = @_run @_serverChain, options
    if result?.failed? then result
    else result?.context?.server

  _run: (chain, options) ->
    # # build options for chain.run(), choose the options which exists
