Thomas
Thomas

Reputation: 182028

Is it possible to build a headless Node-based client from Meteor?

I'm working on a system where a remote machine (hooked up to a projector and some other hardware) is controlled via a Meteor application. Currently, we are using a home-grown DDP client written in C++ to accomplish this, but this approach is not as flexible as I would like:

So I'm toying with the idea of rewriting the Meteor part of the C++ app in JavaScript. What I would like, ideally, is to have a special client of our app (call it headless, akin to to server and client) which:

Even better would be if this client would not contain any of the actual code, but just a piece of bootstrap code. The bootstrapper would download the actual application code from the server and re-download it when the server is updated, in the same way as happens for the HTML client. That would make updates much easier, because we can assume that server and client are always running the same version.

Does such a thing exist? If not, how close can I get without unreasonable effort? Searches for "meteor headless client" and "meteor node client" are not helping me, and the only somewhat related question I could find isn't well answered.

Upvotes: 14

Views: 812

Answers (3)

MrE
MrE

Reputation: 20808

If you wish to use the Meteor client as a headless client, and since client runs in the browser, I'd suggest your look at using a headless browser like PhantomJS, which can run your Meteor code without the UI, and has the ability to access the local file system.

Another option, which is not really what you describe but would make everything javascript, is to use the node ddp client, and write your code in modules you can easily import on the node side.

Upvotes: 1

JeremyK
JeremyK

Reputation: 3240

You should be able to get this to work by using the meteor-desktop package to build your remote headless client.

https://www.npmjs.com/package/meteor-desktop#architecture

In Electron app, there are two processes running along in your app. The so-called main process and renderer process. Main process is just a JS code executed in node, and the renderer is a Chromium process. In this integration your Meteor app is being run in the renderer process and your desktop specific code runs in the main process. They are communicating through IPC events. Basically, the desktop side publishes its API as an IPC event listeners. In your Meteor code, calling it is as simple as Desktop.send('module', 'event');.

This will give you:

  • os access on this (desktop) client
  • hot code push (with caveats around the node modules)
  • provides Meteor.isDesktop to control which code runs on the browser vs the desktop client

Upvotes: 4

Jason Livesay
Jason Livesay

Reputation: 6377

Is there a regular meteor client on the remote machine with custom hardware? Or is that the C++ program acting as a client? And then a server, in addition to your other client browser?

Sounds like you should actually do a few things differently:

  • Set up a dynamic DNS system with a custom domain and port forwarding so you can use the special hardware remote system as a server.

  • Run the Meteor server on that remote machine with hardware.

  • Instead of a full C++ app speaking DDP, just make a Node.js C++ addon that talks to the hardware and use that in the Meteor server code.

Upvotes: -1

Related Questions