Skip to content

Instantly share code, notes, and snippets.

@MeLight
Created August 10, 2012 16:09
Show Gist options
  • Save MeLight/3315278 to your computer and use it in GitHub Desktop.
Save MeLight/3315278 to your computer and use it in GitHub Desktop.
Why don't I get notifications on the client?
//Client
Meteor.autosubscribe(function() {
console.log("Subbed to request");
Meteor.subscribe("requests", Session.get('player_id'), function(){
var call = Requests.findOne();
console.log("in request (call: " +call+")");
Meteor.call("answerCall", call._id);
});
});
//Server
Meteor.publish("requests", function(player_id) {
console.log("player_id: "+player_id+", log count: "+Calls.find({toUser: player_id, status: "request"}).count());
var self = this;
var handle = Calls.find({toUser: player_id, status: "request"}).observe({
added : function(doc) {
self.set("requests", doc._id, doc);
self.flush();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment