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

32 lines
728 B
CoffeeScript
Raw Normal View History

2014-04-14 07:39:18 +08:00
postal = require('postal')
redisrpc = require './redispubsub'
crypto = require 'crypto'
2014-04-14 08:16:37 +08:00
receiveMessage = (callback) ->
postal.subscribe({
channel: replyTo.channel,
topic: replyTo.topic,
callback: (msg, envelope) ->
callback( msg.err, msg.data )
})
2014-04-14 07:39:18 +08:00
2014-04-14 08:16:37 +08:00
exports.sendMessage = (data, callback) ->
2014-04-14 07:39:18 +08:00
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
})