Reputation: 121
I am in the process of building an electron which will eseentially provide "notifications" when a certain form is filled out in a certain service that is connected via oAuth2.
I am having trouble, however, finding any information about the process that (i think) will need to happen.
I am thinking...
a user submits form A from this web service
that web service CAN (not sure if this is the way to go) do a HTTP post to my server
then I was thinking that my server could send that info over to the electron app. I've looked into 'https://www.npmjs.com/package/electron-workers', but i'm still unclear if this could help solve my problem.
Any help or even a nudge in the right direction would be greatly appreciated!
Upvotes: 1
Views: 2962
Reputation: 6080
You have multiple way to do that, but this can only simply be done from the renderer process from Electron (basically your front-end),
Web socket is a technology that enable real-time communication between server and client. The most famous is socket.io. You can have a look at Web Sockets API too.
var checkNotifications = function() {
var r = new XMLHttpRequest();
r.open("POST", "url/of/your/notifications", true);
r.onreadystatechange = function () {
if (r.readyState != 4 || r.status != 200) return;
alert("Success: " + r.responseText);
};
r.send();
}
setInterval(checkNotifications, 5000); // every 5 seconds
Upvotes: 2
Reputation: 572
Electron is running a local node http server, but it's not a public address. Max Ogden has mentioned - I think in the "State of Electron" youtube talk - installing a "headless" electron app on a public webserver to do some service related stuff, but basically you have to have a reachable address. Do you want a desktop webserver to have a public URL?
Upvotes: 0