bigbluebutton-Github/client/bbb-html5-client/lib/messagebus.coffee
2014-04-14 07:58:20 -07:00

32 lines
720 B
CoffeeScript
Executable File

postal = require('postal')
redisrpc = require './redispubsub'
crypto = require 'crypto'
exports.receiveMessage = (callback) ->
postal.subscribe({
channel: "receiveChannel"
topic: "broadcast",
callback: (msg, envelope) ->
callback( msg )
})
exports.sendMessage = (data, callback) ->
replyTo = {
channel: 'model.data',
topic: 'get.' + crypto.randomBytes(16).toString('hex')
};
postal.subscribe({
channel: replyTo.channel,
topic: replyTo.topic,
callback: (msg, envelope) ->
callback( msg.err, msg.data )
}).once()
postal.publish({
channel: 'publishChannel',
topic: 'broadcast',
replyTo: replyTo,
data: data
})