Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streams not working until page refreshed #39

Open
avishekgurung opened this issue Sep 10, 2015 · 0 comments
Open

Streams not working until page refreshed #39

avishekgurung opened this issue Sep 10, 2015 · 0 comments

Comments

@avishekgurung
Copy link

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');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant