bigbluebutton-Github/client/bbb-html5-client/lib/controller.coffee
2014-04-23 18:27:43 -04:00

37 lines
1.1 KiB
CoffeeScript
Executable File

log = require './bbblogger'
config = require '../config'
moduleDeps = ["MessageBus", "ClientProxy"]
module.exports = class Controller
constructor: ->
config.modules.wait moduleDeps, =>
@messageBus = config.modules.get("MessageBus")
@clientProxy = config.modules.get("ClientProxy")
@messageBus.receiveMessages (data) =>
@processReceivedMessage(data)
processReceivedMessage: (data, callback) ->
@clientProxy.sendToClients(data, callback)
processLoginMessage: (data, callback) ->
@messageBus.sendMessage data, (err, result) ->
if err?
errLog = {reason: err, data: data}
log.error({error: errLog}, 'Authentication Failure')
callback(err, null)
else
log.info("SUCCESS: #{result}")
if result.error?
log.info({error: result.error}, 'Authentication Failure')
callback(result.error, null)
else
log.info({response: result.data}, 'Authentication Success')
callback(null, result.data)
# processEndMessage: (data, callback) ->
# @clientProxy.endMeeting()