arunoda / meteor-streams Goto Github PK
View Code? Open in Web Editor NEWRealtime messaging for Meteor
Home Page: http://arunoda.github.io/meteor-streams
License: MIT License
Realtime messaging for Meteor
Home Page: http://arunoda.github.io/meteor-streams
License: MIT License
I think it would be interesting to add the "emit - on" functionality even at server level.
Probably there are other packages that are doing that, but it is interesting to chain notifications with the meteor-streams without the need to install other packages.
Example:
eventStream = new Meteor.Stream('eventstream');
if(Meteor.isServer) {
sendEvent = function(message) {
eventStream .emit('eventName', message);
console.log('event just triggered from server: ' + message);
};
eventStream .on('eventName', function(message) {
console.log('subscriber function triggered : ' + message);
});
}
On documentation page "Communication Patterns": first argument of the function is eventName not userId:
if(Meteor.isServer) {
stream.permissions.write(function(userId, eventName) {
return false;
});
stream.permissions.read(function(userId, eventName) {
return true;
});
Hi, quick question
Is there any way to connect to a Meteor Stream like a normal websocket server using a websocket library? I'm trying to connect to Meteor Streams via an android app but, if I can't do this, I'll probably just implement a normal node.js websocket server instead.
Thanks,
Matthew
Is there some way we could customize the publish/subscribe methods for the collection?
In my use case, I only need to monitor messages dependant on a Session variable.
That is, 95% of my clients don't care at all, and wont render/act upon any notifications.
Were this a normal publish/subscribe, I could base the subscribe upon the Session variables.
While the code runs fine, with the Session variable restrictions being handled in the on()
handler, it's not optimal. All clients are getting all messages
And yes, I know I can restrict based on the Meteor.userId
but in the case of this app, most clients are anon.
chatStream = new Meteor.Stream('chat');
if(Meteor.isClient) {
sendChat = function(message) {
chatStream.emit('message', message);
console.log('me: ' + message);
};
chatStream.on('message', function(message) {
console.log('user: ' + message);
});
}
There was a large blurb about autopublish being enabled so I removed it. However, I tried it with autopublish and it didn't work.
I'm using the latest meteor version 0.6.4.1
Hi there Arunoda,
I started following your work recently and u are amazing guy with lot of good open source codes. Tnx.
I have question. Recently I started using meteor for my projects, and planning for long time to use some WRTC/p2p code to have no server side chat on my app.
Is this that kind of chat ? Where u done need server resources ? If yes, can that be live video chat between clients/users directly and not wasting server resources ?
Stefan
Peace,
Currently there is no such API doc on the docs site. Add it.
We need to send arguments passed to the event in the no-cache mode
It may be same as #43, I made sure that the package didn't work on Meteor 1.3.3 or later.
This package is an important key for my app.
Are there way to work on latest meteor?
Thank you.
Hi.
I have different meteor apps and I want to synchronize streams between them.
A way for cluster (http://arunoda.github.io/meteor-streams/scaling-support.html
) seems not suitable.
Is there any way that a server listens to a stream in another server?
Looks like there isn't a way yet to clean to terminate a stream on the server and release the underlying publications and methods.
Is there something planned for this?
Current implementation uses Pub/Sub and a Method to mimic a Stream. It is not anything bad.
But it will great if we can use the underline Meteor._Stream
[1] as the transport.
While looking at the source, I have found that there are undocumented client disconnection handlers in ther server code, but I can't find a way to use them.
Can you give an example on how they should be implemented?
Hello again,
Is there a way to use this package for internal messaging between registred users ? Not as a live chat app , just exchanged messges 👍
Thanks!
I would like to use streams to create a broadcast channel among all of my instances. In documentation it is written that one can use them for server to server communication, but I don't really see any straightforward way to do it?
Just in stalled Streams and added the standard example code (with correct permissions)
chatStream = new Meteor.Stream('chat');
sendChat = function(message) {
chatStream.emit('message', message);
console.log('me: ' + message);
};
chatStream.on('message', function(message, arg) {
console.log(arg);
console.log('user: ' + message);
});
I run into the following two errors:
Just wondering, is this repo still alive ?
I am using streams to send notification between two applications. The applications are communicating through clusters via redis. Whenever, I push some notification from one app to another, it does not work. But when I refresh the browsers and try, it works.
Can u please tell me what is the problem. My code goes as follows:
App 1 code
function sendMessage(message,date,toUserId,fromUserId,jobId){
ChatStream.emit(toUserId,message,date,toUserId,fromUserId,jobId);
}
ChatStream.on(Meteor.userId(),function(message,date,toUserId,fromUserId,jobId){
var formatDate = moment(date).fromNow();
var index = ClientChat.find().count();
var chatObj = {
from:fromUserId,
message:message,
date:formatDate,
jobId:jobId,
index:index
}
//ClientChat.insert({from:fromUserId,message:message,date:formatDate,jobId:jobId,index:index})
ClientChat.insert(chatObj);
Session.set('receivedPing',chatObj);
})
App2
function sendMessage(message,date,toUserId,fromUserId,jobId){
ChatStream.emit(toUserId,message,date,toUserId,fromUserId,jobId);
}
ChatStream.on(Meteor.userId(),function(message,date,toUserId,fromUserId,jobId){
ClientChat.insert({from:fromUserId,message:message,date:date,jobId:jobId})
})
Cluster.js in server folder
Meteor.startup(function(){
Meteor.Cluster.init();
Meteor.Cluster.sync(ChatStream,LocalNotificationStream);
})
lib folder
ChatStream = new Meteor.Stream('chatStream');
In http://arunoda.github.io/meteor-streams/security.html there is a typo at the last sentence of the last paragraph.
Were it says:
"If cache turned of you can only see..."
Should say:
"If cache turned on you can only see..."
Hi,
I have following code for chat application with channels:
stream.permissions.write(function(eventName, message, channelName) {
var currentUser = Meteor.users.findOne({_id : this.userId});
return _.contains(currentUser.channelsJoined, channelName) // if user joined chat - allow him to send chat stream message
}, false);
}
stream.permissions.read(function(eventName, message, channelName) {
var currentUser = Meteor.users.findOne({_id : this.userId});
return _.contains(currentUser.channelsJoined, channelName) // if user joined chat - allow him to receive chat stream message
}, false);
}
When I pass channel name in emit - write permissions sees it, however in read permissions code channelName argument is undefined. I didn't find much about this in documentation and it seems it should work like that. What I am doing wrong? Or is it a bug? Because permissions without additional parameters is pretty much useless in real world scenarios...
Is there any way to create some presence APIs that can be used to find out who is listening on a stream?
Homepage-Example: Your app is crashing. Here's the latest log.
/Applications/MAMP/htdocs/frequentis/ms-homepage/.meteor/local/build/server/server.js:337
}).run();
^
TypeError: undefined is not a function
at app/server-to-client.js:1:32
at /Applications/MAMP/htdocs/frequentis/ms-homepage/.meteor/local/build/server/server.js:298:12
at Array.forEach (native)
at Function..each..forEach (/Users/manfredspecht/.meteor/tools/cc18dfef9e/lib/node_modules/underscore/underscore.js:78:11)
at run (/Applications/MAMP/htdocs/frequentis/ms-homepage/.meteor/local/build/server/server.js:239:7)
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.
HI Arunoda :
I need to send values of a counter on server side which gets changed evey 80 miliseconds to all clients. The reason for this is to move an object on a canvas for all clients base on this counter. I used MongoDb and Publish /Subscribe first . But I am not getting some of the updates to the server side counter in clients . So I need another solution and I ran into Your stream package. Before implementing it, wanted to see if this is the right solution or you know of any better supported mechanism .
Thanks for your suggestions.
Hey everyone,
I was wondering if this method would be even possible using streams but is it possible to add rooms? I have tried several different ways but I am having trouble getting it to work. Do I need to add clusters? Any help would be greatly appreciated!
I have failed to add the meteor streams to my projects
using meteor add streams but iam just getting this error
rrors while parsing arguments:
While adding package streams:
error: no such package
var messaging = new Meteor.Stream('messaging');
Meteor.methods({
"adLogin" : function(req){
if( req.username && req.domain && req.password){
var retval = adLogin(req.username, req.domain, req.password);
} else {
console.log('não recebi os parâmetros que preciso.', req);
return false;
}
if (retval.success == true){
return retval.result;
}
console.log(retval.result);
messaging.emit('loginProcessFailed', retval.result);
return false;
}
});
The method always ends before the actions of "messaging" happen.
Why?
I've built a complex app with Meteor Streams for creating shared web IDE sessions, and running server languages (ex: Java) through this code editor by sending the code and then getting back the execution result from the server.
So inside the execution of the app (the one the user wrote in their IDE) I'm listening to a stream event to handle server side I/O apps in real-time, however, this works fine in the first run, but when re-running the app (using the same event), I get the error "Error: This socket has been ended by the other party" which is an exception and it stops the execution there.
Is there any ideas on this issue, why is it happening? and is there a way to re-connect to the stream/socket when it's ended or closed?
Hi Arunoda
I have a requirement for streaming live video from my phone camera and/or attaching a photo to the blackboard.
Is this possible?
Many Thanks
Leon
Looks like the package has been published to Atmosphere in in August 2014, but the last commit here is from Sep 2013?
Also, would be nice to add the git URL to package.js so the README shows up at https://atmospherejs.com/arunoda/streams
It would be nice if I can register on a stream to get notified after a client has established a connection to the server.
In my current project I need this to initialize a context object for each client on the server. Hence, I have to check in every listening (server) method if such a context is already available. In case not, a new context object is created.
This is not really an issue but I can't seem find help anywhere else.
I'm creating a simple multiplayer pong game with 2 players.
Each player should only be able to control their respective paddle. So in theory I would send a message to client 1 saying 'control_paddle_one' to client 2 I would send 'control_paddle_two'.
I did this in socket.io by using io.sockets.socket(id).emit('message').
Is there a way to accomplish this using streams?
Thank you!
Having an issue integrating Meteor-Streams to the application i am creating. The design i am doing is much more similar to Streaming Private Page communication pattern. What will happen is that i have 2 text area with TO and the Message. In the TO field it is the recipient of the message and the MESSAGE field is the main message.
Issue: Meteor-Streams should only send the message to the designated recipient on the TO FIELD, NOT ALL USERS THAT IS ACTIVE. Is there a way on how will i approach this?
How do I close a stream on the Client or Server and stop receiving callbacks?
Meteor will probably have this batching feature merged in.
I think as a consequence, meteor streams will stop working.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.