ghamm Posted December 21, 2016 Posted December 21, 2016 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 Quote
Ron Posted December 22, 2016 Posted December 22, 2016 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. Quote
ghamm Posted December 22, 2016 Author Posted December 22, 2016 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. Quote
Harry Rogers Posted December 22, 2016 Posted December 22, 2016 This Delphi ( & JS ) socket library is certainly worth a look. http://www.esegece.com/websockets/#wsfeatures Quote
docjones Posted December 22, 2016 Posted December 22, 2016 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. Quote
Oliver Morsch Posted December 22, 2016 Posted December 22, 2016 Web sockets is the more modern way, but i think long polling is easier.I used here and here. Quote
ghamm Posted December 22, 2016 Author Posted December 22, 2016 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 Quote
Ron Posted December 22, 2016 Posted December 22, 2016 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. Quote
ghamm Posted December 25, 2016 Author Posted December 25, 2016 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? Quote
Oliver Morsch Posted December 25, 2016 Posted December 25, 2016 A timer is a easy solution (if there are not too much sessions). But where is the problem with long polling (above examples)? Quote
Ron Posted December 26, 2016 Posted December 26, 2016 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! Quote
gordon Posted December 29, 2016 Posted December 29, 2016 I guess I will have to test and see what sort of bandwidth is used to fire a timer every 2 seconds etc.. maybe its not that bad Quote
ghamm Posted January 13, 2017 Author Posted January 13, 2017 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.. Quote
molla2005b Posted January 18, 2017 Posted January 18, 2017 hi mybe this match your need https://market.sencha.com/extensions/ext-ux-data-proxy-websocket Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.