     type        : 'fanout'
     autoDelete  : yes
 
-  constructor:(@bongo, @resourceName, @presenceExchange='services-presence')->
+  NOTIFICATION_EXCHANGE_OPTIONS = 
+    type        : 'direct'
+    autoDelete  : yes
+
+  constructor:(@bongo, options = {})->
+    { @presenceExchange, @notificationExchange } = options
+    @presenceExchange     ?= 'services-presence'
+    @notificationExchange ?= 'notification-control'
     @services = {}
     @clients  = {
       bySocketId    : {}

    clientsByExchange.push client

  rejectClient:(routingKey, message)->
    return console.trace()  unless routingKey?
    @bongo.respondToClient routingKey, {
      method    : 'error'
      arguments : [message: message ? 'Access denied']
      callbacks : {}
    }

  joinClient: do ->


                          message = JSON.stringify secretChannelName
                          @bongo.respondToClient setSecretNameEvent, message

    joinClientNotificationHelper =(messageData, routingKey, socketId)->
      fail = (err)=>
        console.error err  if err
        @rejectClient routingKey

      @authenticate messageData, routingKey, (session)=>
        unless session then fail()
        else if session?
          {username} = session
          @fetchNotificationExchange (exchange)->
            exchange.publish 'auth.join', {routingKey, username}

    joinClient =(messageData, socketId)->
      {channel, routingKey, serviceType} = messageData
      switch serviceType
        when 'bongo', 'kite'
          joinClientHelper.call this, messageData, routingKey, socketId
        
        when 'group'
          unless ///^group\.#{messageData.group}\.///.test routingKey
            return @rejectClient routingKey
          joinClientGroupHelper.call this, messageData, routingKey, socketId
        
        when 'chat' then # TODO: handle authentication for chat
        
        when 'notification'
          unless ///^notification\.///.test routingKey
            return @rejectClient routingKey
          joinClientNotificationHelper.call this, messageData, routingKey, socketId
        
        when 'secret'
          @addClient socketId, routingKey, routingKey, no
        
        else
          @rejectClient routingKey  unless /^oid./.test routingKey
          # TODO: we're not really handling the oid channels at all (I guess we don't need to) C.T.

  cleanUpClient:(client)->
    @removeClient client
