Comments (7)
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.
Hi Arunoda,
Thanks for the reply. I will try this out..
from meteor-streams.
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.
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.
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.
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.
👍
from meteor-streams.
Related Issues (20)
- Need updated for 0.9.0 HOT 25
- How does one use streams for server to server communication?
- client2client, WRTC, p2p ? HOT 2
- Connect to Meteor Stream Externally
- Git push? HOT 2
- Target a specific client from the server.
- Can a server listen to a stream in another server? HOT 1
- Still alive? HOT 2
- Streaming Video Camera HOT 1
- Additional parameters is null in read permissions HOT 4
- Feature HOT 1
- Minor typo in html documentation HOT 2
- It does not work inside a method
- send frequent data to clients HOT 1
- Streams not working until page refreshed
- emit not working - not emiting to all clients and Random is not defined. HOT 5
- Your app is crashing. Here's the latest log. HOT 1
- i have failed to add meteor streams to my project
- Possiblity breaking changes in new Meteor version HOT 3
- The package doesn't work on Meteor 1.3.3 or later. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-streams.