Giter VIP home page Giter VIP logo

Comments (7)

arunoda avatar arunoda commented on August 21, 2024

How about this solution.

stream = new Meteor.Stream('private');

if(Meteor.isClient) {
  stream.on(Meteor.userId(), function(message) {
    alert('new message:', message);
  });

  sendMessage = function(message, to) {
    //to is an array of userIds (in your to field)
    stream.emit('send', message, to);
  }
}

if(Meteor.isServer) {
  stream.permissions.write(function(eventName) {
    return eventName == 'send';
  });

  stream.permissions.read(function(eventName) {
    return this.userId == eventName;
  });

  stream.on('send', function(message, to) {
    to.forEach(function(userId) {
      stream.emit(to, message);
    });
  });
}

from meteor-streams.

liveitchina avatar liveitchina commented on August 21, 2024

Hi Arunoda,

Thanks for the reply. I will try this out..

from meteor-streams.

ggmacasaet avatar ggmacasaet commented on August 21, 2024

Hi Arunoda,

Does the solution you provided has already a collection attached to it? or that is only reachable if the Receiving User is online?

from meteor-streams.

arunoda avatar arunoda commented on August 21, 2024

I simply use Meteor.userId() for the demonstration purpose. You can use a nickname, random string or anything depending on your app.

from meteor-streams.

ggmacasaet avatar ggmacasaet commented on August 21, 2024

Hi Arunoda,

Sorry for the confusion. What i meant is that are the messages already STORED inside a collection so that whenever a user has logged in he/she can already see the message that is intended for them?

from meteor-streams.

arunoda avatar arunoda commented on August 21, 2024

Okay. Now I got it.

Meteor Streams does not handle the message persistence. You can use stream
filters http://arunoda.github.io/meteor-streams/filters.html to store
messages to the db.
So, in the very first you can get messages via a meteor method or using
streams itself.

Is this answer your question?

On Mon, Oct 21, 2013 at 4:39 PM, ggmacasaet [email protected]:

Hi Arunoda,

Sorry for the confusion. What i meant is that are the messages already
STORED inside a collection so that whenever a user has logged in he/she can
already see the message that is intended for them?


Reply to this email directly or view it on GitHubhttps://github.com//issues/13#issuecomment-26708570
.

Arunoda Susiripala

@arunoda http://twitter.com/arunoda
http://gplus.to/arunodahttps://github.com/arunoda
http://www.linkedin.com/in/arunoda

from meteor-streams.

iwoork avatar iwoork commented on August 21, 2024

👍

from meteor-streams.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.