Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broadcast names not distinguishing broadcasts. #2

Open
trusktr opened this issue Jun 28, 2017 · 2 comments
Open

Broadcast names not distinguishing broadcasts. #2

trusktr opened this issue Jun 28, 2017 · 2 comments

Comments

@trusktr
Copy link
Contributor

trusktr commented Jun 28, 2017

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.

@trusktr
Copy link
Contributor Author

trusktr commented Jun 28, 2017

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.

@trusktr
Copy link
Contributor Author

trusktr commented Jun 28, 2017

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');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant