Jump to content

Messaging Push Notify etc.


ghamm

Recommended Posts

Hi,

Im curious.. lets say I want to write an app, with a graph etc.. maybe Im monitoring stats on a machine, RPM, temperature etc.. Can messages or push notifies be send to my  browser? 2 way messaging? Does unigui web app  maintain a async connection with the server?

 

If not , I guess Id have to do polling, yuck..

 

 

Gordon

Link to comment
Share on other sites

What may work, is using an uniHTMLFrame, containing some

javascript, where you load a websocket client, which then

connects to a websocket server you have running, like a nodejs server.

 

I am in the process of trying this, and I'm going through the various

websocket js libraries around, and I was able to connect with one

of them, think it was Faye, to a nodejs server, but there was some other issues,

so I kept looking. Going to take another closer look in some days.

 

A list of such libraries is here: https://deepstream.io/blog/realtime-framework-overview/

 

Maybe it is possible to find a working library - I don't know - some of them use

their own client libraries, and others use the raw websocket client.

 

I need to broadcast db changes to all connected clients in real time,

triggering the client to load the update, if relevant.

Link to comment
Share on other sites

That sounds interesting.. Im pretty strong in TCPIP, but really know nothing about Javascript etc.. thats one challenge I have.  I was hoping that my messages could come through the context of my Unigui session/thread. that would be the easiest.

 

I got thinking, what actually happens with a timer? Does it actually reload the whole page as a request? Or can you change dataaware grids/fields on the Fly? I was thinking that UniGui was NOT totally stateless, but maybe it is?

 

Really, Im trying avoid writing an IOS app, and using UniGui to connect to IOT type stuff.

Link to comment
Share on other sites

I think that you can use mormot framework server / client.

 

Create a mormot server that have the services / push notifications.

add a mormot client to your form, or unimainmodule

 

or  easy way , your server save your data in a table , and unigui refresh data-table / unicontrols in unitimer.

Link to comment
Share on other sites

Thank you for all of the feedback..

Im excited to play with the Websocket stuff, it looks great.

I dont have any trouble getting messages to and from my delphi UNIGUI server.. Maybe Im just making this harder than it needs to be.. but I cant see how my browser (That is running HTML5 unigui) and get a message real time from my server or some other place. Im thinking I need some sort of JS component in my app?

 

Also, I like the ease of using long polling..ive used that before .. Im not clear what server Im long polling?

 

Sorry for my lack of understanding

Link to comment
Share on other sites

You are long polling the unigui server through the client instance,

which has the db connection and thus access to the fresh data,

or another webserver that you set up somewhere, that has

access to the data you need.

 

For instance, I have a cash drawer and receipt printer installed locally

with the customer, and when the cash drawer is opened, I make an http

call to the local windows service controlling the cash drawer, which is

running an http webserver, and within that service I do not respond

to the http call until the drawer is closed.

 

On the unigui end I pick up the fresh db results as the http blocking

long polling call finishes, because I then know the service app has

saved the cash drawer state to the db.

 

From a uniHTMLFrame I assume you can do some of the same stuff,

make a long polling ajax call somehow, to the unigui server through the

client instance.

 

I also have the option of a timer, instead of long polling, to get the

cash drawer status, and the last option is no checking of status.

 

But new regulations now demand that no POS transactions may be

done while the drawer is opened, so that state must be logged.

Link to comment
Share on other sites

Maybe Im making this harder than I need it to.. Maybe just a timer every few seconds would not be that big of a deal.  I would be much more elegant to have some push notify from the server using websockets etc.. But I dont understand the underlying architecture with Unigui, to know how to implement something like that.. Im also lost in the JS stuff. For now, maybe just a timer/refresh?

Link to comment
Share on other sites

I guess it all depends on the nature of the signal that you are monitoring,

i.e. the rate of change, the predictability of that range or the function of change.

 

If it is RPM, which changes constantly like every second, you might as well

use a timer, as you will be sending/getting data every second anyway.

 

No point in making it complex if you always know when the data comes.

 

However, if the data changes now and then, and it is a point to keep

the client/server communication to a minimum, and critical to get the

update when it comes, then a more complex solution might be in place.

 

There is nothing wrong with a timer in itself, and you can log it, and

set up other systems to monitor it and whatever. Your box is run by

a Ghz timer, and it works great, so timers are super basic in computer systems.

Without them, like in the form of crystals, we would have nothing.

Timers are like frequencies, or patterns, symphonies of energy...

they are the building blocks of the entire universe etc etc...don't fool with timers! :)

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

Ive got my app working with a timer.. but still feel that ist not very elegant.. I would still like any ideas how to update gauges and controls with some sort of message when data changes on the server.
Im trying to get around writing a real app, but banging my head against the wall trying to find an elegant way. I sure wish i understood JS and web stuff more..

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...