Broadcast names not distinguishing broadcasts.
trusktr opened this issue · comments
I have one client listening like this:
let deviceOrientation1 = {}
const broadcast1 = new Meteor.Broadcast('orientation1')
broadcast1.on('data', data => {
Object.assign(deviceOrientation1, data)
})
let deviceOrientation2 = {}
const broadcast2 = new Meteor.Broadcast('orientation2')
broadcast2.on('data', data => {
Object.assign(deviceOrientation2, data)
})
let deviceOrientation3 = {}
const broadcast3 = new Meteor.Broadcast('orientation3')
broadcast3.on('data', data => {
Object.assign(deviceOrientation3, data)
})
And I have three other clients broadcasting to each named broadcast:
let broadcast1 = new Meteor.Broadcast('orientation1')
const o1 = {...}
broadcast1.send(o1)
let broadcast2 = new Meteor.Broadcast('orientation2')
const o2 = {...}
broadcast2.send(o2)
let broadcast3 = new Meteor.Broadcast('orientation3')
const o3 = {...}
broadcast3.send(o3)
And the server code is
let broadcast = new Meteor.Broadcast
However, it seems that the first listening client receives all 3 datas into the deviceOrientation1
object, from all three clients! meteor-broadcast
doesn't seem to be separating the data to the separate broadcast
channels, and deviceOrientation2
and deviceOrientation3
never change, only deviceOrientation1
changes based on all three of the other clients.
I was hoping they would all be separate.
Up until now, I was only using a single device to broadcast orientation1
, but I have now added two more devices and realized this issue.
I tried changing the server code to
let broadcast1 = new Meteor.Broadcast('orientation1')
let broadcast2 = new Meteor.Broadcast('orientation2')
let broadcast3 = new Meteor.Broadcast('orientation3')
but that didn't work (and looking at the code it seems like Broadcast
is meant to be a singleton.
I was able to use rocketchat:streamer
to accomplish it in a similar way, so the codes are like this:
clients:
const streamer = new Meteor.Streamer('orientation')
streamer.on('orientation1', data => {
Object.assign(deviceOrientation1, data)
})
streamer.on('orientation2', data => {
Object.assign(deviceOrientation2, data)
})
streamer.on('orientation3', data => {
Object.assign(deviceOrientation3, data)
})
let streamer = new Meteor.Streamer('orientation')
const o = {x, y, z}
streamer.emit('orientation1', o)
let streamer = new Meteor.Streamer('orientation')
const o = {x, y, z}
streamer.emit('orientation2', o)
let streamer = new Meteor.Streamer('orientation')
const o = {x, y, z}
streamer.emit('orientation3', o)
server:
let streamer = new Meteor.Streamer('orientation')
streamer.allowRead('all');
streamer.allowWrite('all');