I am wondering If possible/how to connect to Meteor from a non meteor app. maybe through DDP ?
1 Like
Yes, it is possible to talk to any Meteor server from anywhere, as long as you can open a websocket. You just need to follow the DDP protocol.
As an example, take a look at my unity3d-ddp-client project.
Never used, but Asteroid is a NPM package that lets you connect and subscribe to an external Meteor backend elegantly through DDP:
import {createClass} from "asteroid";
const Asteroid = createClass();
// Connect to a Meteor backend
const asteroid = new Asteroid({
endpoint: "ws://localhost:3000/websocket"
});
// Use real-time collections
asteroid.subscribe("tasksPublication");
asteroid.ddp.on("added", ({collection, id, fields}) => {
console.log(`Element added to collection ${collection}`);
console.log(id);
console.log(fields);
});
// Login
asteroid.loginWithPassword({username, email, password});
// Call method and use promises
asteroid.call("newUser")
.then(result => {
console.log("Success");
console.log(result);
})
.catch(error => {
console.log("Error");
console.error(error);
});
This list may be a little out-of-date, but could be worth a look:
1 Like
Here’s an example Node.js command-line utility using the ddp package from npm (one of the many options listed on the excellent meteorpedia page @robfallows linked to)
1 Like