Meteor Streams : client doesn't receive streams -


i'm working on simple app based on meteor , meteorstreams. aim simple : 1 user click on button create room other users join room users can emit streams simple message creator listen message , display them

in fact : message other users sent (log in server script), creator doesn't receive them. if reload page of creator, messages sent other user.

i don't understand why doesn't work first time.

i use meteor-router routing system. code can seen here

https://github.com/rebolon/meetingtimecost/tree/feature/pokervoteprotection

for client side code availabel in client/views/poker/* , client/helpers server stream's code in server/pokerstreams.js

application can tested here : http://meetingtimecost.meteor.com creator must logged.

if have idea, welcome. thanks

ok, ok, after doing debugging, understand wrong in code : it's easy in fact. problem comes fact forgot bind stream.on event deps.autorun. result part of code not managed reactivity never re-run automatically when session changed.

the solution easy meteor : wrap part of code inside deps.autorun

meteor.startup(function () {   deps.autorun(function funcreloadstreamlisteningonnewroom () {     pokerstream.on(session.get('currentroom') + ':currentroom:vote', function (vote) {       var votefound = 0;       // update allowed       if (session.get('pokervotestatus') === 'voting') {         votefound = vote.find({subscriptionid: this.subscriptionid});         if (!votefound.count()) {           vote.insert({value: vote, userid: this.userid, subscriptionid: this.subscriptionid});         } else {           vote.update({_id: votefound._id}, {$set: {value: vote}});         }       }     });   }); }); 

so not meteor streams problem, fault. hope people understand outside template , collection, need wrap code inside deps if want reactivity.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -