I would like to send some data to a Meteor server, from a small bit of Javascript on a third-party domain. I would like to send lots of small things, as they happen, so I would like to use an io-socket.
I can imagine a few ways of doing this:
Connect to meteor's socket-io and "piggyback" it. Send custom events (namespaced to avoid collision), and somehow catch these on the server side. But I can't find the socket object to attach to on the server!
Connect to meteor's socket-io, and pretend to be a meteor client. Catch messages with standard meteor functions on the server side. Is it possible to talk like a meteor client without a lot of protocol?
Open a second IO socket listener on the server, and have clients attach to that. For that I would need to find the 'app' object.
Run a completely separate Node process and have clients talk to that; it could save in the same MongoDB that Meteor uses. I could do this, but I liked the idea of keeping everything in one process. Also, I'm not sure if it would fire update events in Meteor.
I would really like help with #1: Where can I find the iosocket object on the server?
Failing that, is #2 feasible? How can I talk like a Meteor client?
You mentioned some good options, and the DDP client is probably the most robust way to go. However, you can just set up normal Node.js REST API endpoints using the webapp package (meteor add webapp).
WebApp.rawConnectHandlers and WebApp.connectHandlers are just instances to which you can attach connect/express middleware or handlers.
If you write to the MongoDB directly, it will fire events in Meteor, as long as you set up the oplog observe driver.