I have two applications that I need to synchronise. One of them will receive data from users and the other will display the data. Both applications will work on different servers. They could be disconnected at some times and they need to continue working until reconnect, so I will replicate the data from the first application on the second application.
On Meteor documentation I found DDP.connect(url)
but I'm not sure how to use it. I found many questions and examples connecting non Meteor applications with Meteor using DDP, but nothing about connecting two Meteor applications.
My first approach was something like this:
Application 1
Items = new Meteor.Collection('items');
Items.insert({name: 'item 1'});
if (Meteor.isServer) {
Meteor.publish('items', function() {
return Items.find();
});
}
Application 2
Items = new Meteor.Collection('items')
if (Meteor.isServer) {
var remote = DDP.connect('http://server1.com/);
remote.onReconnect = function() {
remote.subscribe('items');
var items = Items.find();
console.log(items.count()); // expected to be 1 but get 0
}
}
On the second application, how can I get the items from the first application?