Created
November 15, 2012 15:07
-
-
Save papercreatures/4079065 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config = require("netdev-share").config | |
log = require("netdev-share").logger.main() | |
util = require("util") | |
_ = require("underscore") | |
drumWrapper = require("drum-amqp-wrapper") | |
myDrumAppInfo = drumWrapper.drumConventions.getDrumAppInfo("conferenceapp") | |
brokerHosts = config.amqp.brokerHosts | |
switchDrumAppInfo = drumWrapper.drumConventions.getDrumAppInfo("switch") | |
drumWrapper.setLogLevel config.amqp.logLevel or "INFO" | |
module.exports = class Inject | |
constructor: (@csid) -> | |
@callers = [] | |
connect: (cb = ->) => | |
drumWrapper.establishDrumConnection myDrumAppInfo, brokerHosts, @responses, @responses, (res) -> | |
if drumWrapper.resultCodes.CONNECTED_OK == res then cb() else cb(true, res) | |
startConference: => | |
addCaller: (opts) => | |
log.info "Adding caller", opts | |
@startConference() unless @callers.length | |
@callers.push opts | |
@send "memberJoined", | |
status: | |
callers: [] | |
removeCaller: (caller) => | |
send: (type, body) => | |
topic = switchDrumAppInfo.topics.loadbalanced | |
message = drumWrapper.drumEvent.newEvent() | |
.extend(@templates[type]) | |
.extend(body: body) | |
log.info "Sending message to #{topic}", message | |
drumWrapper.send topic, message, (res) -> | |
log.info res | |
templates: | |
status: | |
head: | |
type: "confStatus" | |
body: | |
trigger: "statusReport" | |
memberJoined: | |
head: | |
type: "confStatus" | |
body: | |
trigger: "dialinJoined" | |
responses: | |
general: | |
template: { head: { }, body: { }} | |
handler: -> log.error('here') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment