JavaScript Meteor stream not working until browser page refreshed

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

The packages I am using are of arunoda streams http://arunoda.github.io/meteor-streams/

Answer:1

How do I add an index to a previously created object store, within the upgrade needed event? Doing this on a new object store is well documented: request.onupgradeneeded = function(event) { var db ...

How do I add an index to a previously created object store, within the upgrade needed event? Doing this on a new object store is well documented: request.onupgradeneeded = function(event) { var db ...

  1. adding index to existing table sql server
  2. adding index to existing table in mysql
  3. adding index to existing table oracle
  4. adding index to existing table
  5. adding column to existing index in oracle

I am using momentJS in a project and I have a function that takes a month and year and returns the last day of the month using those parameters. Everything is working fine, Jan - November, and as ...

I am using momentJS in a project and I have a function that takes a month and year and returns the last day of the month using those parameters. Everything is working fine, Jan - November, and as ...

  1. moment last month first day
  2. moment last month
  3. moment last month date
  4. moment month last day
  5. moment get last month
  6. moment js last month
  7. moment get last month start and end date
  8. moment get last month date
  9. moment js last month day
  10. moment get last month name
  11. moment get last month range
  12. moment js get last month
  13. moment start of last month
  14. moment get month last day
  15. moment end of last month
  16. moment last week of month
  17. moment last sunday of month
  18. moment last day of previous month
  19. moment js start of last month
  20. moment last day of current month

In this JSFiddle I have implemented elements in svg. I want the group of elements to be draggable and I have tried it with d3.drag and using transform:translate. The drag is not smooth. It flickers ...

In this JSFiddle I have implemented elements in svg. I want the group of elements to be draggable and I have tried it with d3.drag and using transform:translate. The drag is not smooth. It flickers ...

I'm just starting to document some Javascript code that I've written and I have a question. Looking through my vendor directory to see how the 3rd party packages do it, I've noticed that many of them ...

I'm just starting to document some Javascript code that I've written and I have a question. Looking through my vendor directory to see how the 3rd party packages do it, I've noticed that many of them ...