         @broadcastOwnMessage messageBody, PUBLIC, name
 
     # Delegates to the channel to handle received message
-    @broadcaster.on channelName, (msg) ->
-      channel.messageReceived msg
+    @broadcaster.on channelName, (msg) =>
+      @deliverMessageToChannel channel, msg
 
     @channels[name] = channel
 

  loadView:(mainView)->
    @joinChannel "@#{@username}"
    @joinChannel PUBLIC
    @joinChannel "#koding"

  joinChannel: (name) ->
    return @channels[name] if @channels[name]

    @broadcaster.emit channelMQName, JSON.stringify(chatItem)
    return unless @channels[toChannel]
    #chatItem.author = "me"
    @deliverMessageToChannel @channels[toChannel], chatItem

  deliverMessageToChannel: (channel, message) ->
    itemInstance = channel.messageReceived message
    itemInstance.registerListener
      KDEventTypes: 'click'
      listener    : @
      callback    : (pubInst, event) =>
        return unless $(event.target).is('a.open-new-chat')
        channelName = $(event.target).text()
        @joinChannel channelName

  fetchAutoCompleteForMentionField:(inputValue,blacklist,callback)->
    bongo.api.JAccount.byRelevance inputValue,{blacklist},(err,accounts)->
