bigbluebutton-Github/client/bbb-html5-client/lib/controller.coffee

36 lines
1.2 KiB
CoffeeScript
Raw Normal View History

config = require '../config'
log = require './bbblogger'
2014-04-14 22:58:20 +08:00
moduleDeps = ["MessageBus", "ClientProxy"]
2014-04-14 22:58:20 +08:00
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)
# Processes a message requesting authentication
processAuthMessage: (data, callback) ->
log.info({ data: data }, "Sending an authentication request and waiting for reply")
@messageBus.sendAndWaitForReply data, (err, result) ->
if err?
log.error({ reason: err, result: result, original: data }, "Authentication failure")
callback(err, null)
2014-04-14 07:39:18 +08:00
else
if result.payload?.valid
log.info({ result: result }, "Authentication successful")
callback(null, result)
else
log.info({ result: result }, "Authentication failure")
callback(new Error("Authentication failure"), null)
# processEndMessage: (data, callback) ->
# @clientProxy.endMeeting()