Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Meteor.publish("subscriptions", function(ghash) {
- userId = this.userId;
- //console.log(this._session.socket.meteor_session.collectionViews.groups);
- if(this._session.socket) {
- if(this._session.socket._events.data.length === 1) {
- this._session.socket.on("data", Meteor.bindEnvironment(function(data) {
- //console.log(JSON.parse(data));
- var method = JSON.parse(data).method;
- var submsg = JSON.parse(data).msg;
- var subid = JSON.parse(data).id;
- if(submsg === 'sub') {
- if(JSON.parse(data).params && JSON.parse(data).name === 'subscriptions') {
- console.log('---------------- SUB ----------------');
- var ghash2 = JSON.parse(data).params[0];
- if(ghash == ghash2)
- Subscriptions.insert({id: subid, ghash: ghash});
- }
- }
- if(submsg === 'unsub') {
- console.log('--------------- UNSUB ---------------');
- Subscriptions.remove({id: subid});
- }
- console.log(Subscriptions.find().fetch());
- }, function(e) {
- console.log(e);
- }));
- this._session.socket.on("close", Meteor.bindEnvironment(function(data) {
- console.log(data);
- }, function(e) {
- console.log("close error", e);
- }));
- }
- }
- console.log(Subscriptions.find().fetch());
- return Subscriptions.find();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement