* * *

Author Topic: Customer Display server and webpage [Solved]  (Read 679 times)

lainz

  • Hero Member
  • *****
  • Posts: 2766
  • I'm coding :)
    • Lainz
Customer Display server and webpage [Solved]
« on: July 03, 2018, 07:06:36 pm »
Hi,

I need to make a Customer Display, something like is used in the banks or pharmacy for turns, but instead of showing who is next, showing the details of the buy in progress: list of products with price, total, method of payment, etc.

The data is inside a Lazarus application for Windows. I want to make a local web server that shows a webpage with that data, the server need to communicate with the GUI application to update the data.

What do you think will be a good way?

I think this is an option:
- GUI application sends the data to the local server
- Web Page served with the local server do a Get constantly to an endpoint in the same local server to bring the data in JSON, then is parsed and displayed (like for example using AngularJS - is the one I know)

But the main problem is that:
- I need to do Get requests constantly

And is not a problem of updating the list of products, due how is AngularJS is designed, it can update lists efficiently.

This needs to be a webpage, because I can show that information for example in a Tablet, if the commerce doesn't have a second monitor or a hardware capable of having 2 monitors.

Also I will show ads when there is no buy in progress..
« Last Edit: July 04, 2018, 04:24:27 pm by lainz »

taazz

  • Hero Member
  • *****
  • Posts: 5136
Re: Customer Display server and webpage
« Reply #1 on: July 03, 2018, 08:41:39 pm »
Yes that is the nature of stateless application. Once the html is created there is no state to compare against for changes. You need to re query the data again. Or are you trying to create a known state using websockets to push data back? This will have the side effect of a page that never ends loading.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

lainz

  • Hero Member
  • *****
  • Posts: 2766
  • I'm coding :)
    • Lainz
Re: Customer Display server and webpage
« Reply #2 on: July 03, 2018, 09:01:16 pm »
The page is only to be seen by the user, there will be no interaction at all, and will be running fullscreen.

And yes, with my idea this will never end loading data, it will be always communicating. I'm just starting the website html + css template, so I've not touched any code yet.

Option 1:
I will not serve static html only, but also JS that will do the 'Get' to a JSON endpoint every say, 4 seconds or less, I already used Brook Framework and works very fast as an endpoint.

So the webpage is only the structure, and that will be changed with the data by AngularJS code.

The delay will be sending the data from the GUI to the server, and from the server to the web app.

Option 2:
The other way is reloading the static HTML entirely made by the webserver, so there's no communication in that way, only a full page reload, no usage of AngularJS.

The delay is only between GUI desktop app and the server, then the build of the HTML, and showing that in the browser.

taazz

  • Hero Member
  • *****
  • Posts: 5136
Re: Customer Display server and webpage
« Reply #3 on: July 03, 2018, 09:13:30 pm »
The page is only to be seen by the user, there will be no interaction at all, and will be running fullscreen.

And yes, with my idea this will never end loading data, it will be always communicating. I'm just starting the website html + css template, so I've not touched any code yet.

Option 1:
I will not serve static html only, but also JS that will do the 'Get' to a JSON endpoint every say, 4 seconds or less, I already used Brook Framework and works very fast as an endpoint.

So the webpage is only the structure, and that will be changed with the data by AngularJS code.

The delay will be sending the data from the GUI to the server, and from the server to the web app.

Option 2:
The other way is reloading the static HTML entirely made by the webserver, so there's no communication in that way, only a full page reload, no usage of AngularJS.

The delay is only between GUI desktop app and the server, then the build of the HTML, and showing that in the browser.
go with option 2 in both of your cases the server will be hit in intervals for data the difference comes down between a json and a html page, it does not look that big (unless we are talking images).
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

sash

  • New member
  • *
  • Posts: 42
Re: Customer Display server and webpage
« Reply #4 on: July 03, 2018, 10:08:51 pm »
I'm not sure I got your exact task, but in any case you don't need to refresh whole web page constantly.
There's a "server push" technique, for example a longpoll script.
Lazarus 1.8.4 Unversioned directory FPC 3.0.4 x86_64-linux-gtk2

lainz

  • Hero Member
  • *****
  • Posts: 2766
  • I'm coding :)
    • Lainz
Re: Customer Display server and webpage
« Reply #5 on: July 04, 2018, 02:15:56 am »
We're trying now to use websockets with an Indy udp server. To send data directly to the page from the GUI application and process that with angularjs.

Let's see if it works, is far more simple this way.

taazz

  • Hero Member
  • *****
  • Posts: 5136
Re: Customer Display server and webpage
« Reply #6 on: July 04, 2018, 03:06:10 am »
We're trying now to use websockets with an Indy udp server. To send data directly to the page from the GUI application and process that with angularjs.

Let's see if it works, is far more simple this way.
very interesting, I'd like to have a look on that sample or read a blog post about it, what ever works better.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

lainz

  • Hero Member
  • *****
  • Posts: 2766
  • I'm coding :)
    • Lainz
Re: Customer Display server and webpage
« Reply #7 on: July 04, 2018, 04:12:06 am »
Well seems that there is only a paid websockets component.

The other component I found is out of date and not working according to the repo readme...

UDP can't be used with websockets.

Maybe with webrtc but I have no idea.
« Last Edit: July 04, 2018, 04:27:38 am by lainz »

lainz

  • Hero Member
  • *****
  • Posts: 2766
  • I'm coding :)
    • Lainz

taazz

  • Hero Member
  • *****
  • Posts: 5136
Re: Customer Display server and webpage
« Reply #9 on: July 04, 2018, 05:51:30 am »
Oh I see. thanks for the info.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64


lainz

  • Hero Member
  • *****
  • Posts: 2766
  • I'm coding :)
    • Lainz
Re: Customer Display server and webpage
« Reply #11 on: July 04, 2018, 03:29:01 pm »
Thanks. I will try them.

Edit: Installed mormot with FPCUpDeluxe with my current Lazarus setup, and tested the demo and works fine, thanks  :)
« Last Edit: July 04, 2018, 04:24:07 pm by lainz »

lainz

  • Hero Member
  • *****
  • Posts: 2766
  • I'm coding :)
    • Lainz
Re: Customer Display server and webpage [Solved]
« Reply #12 on: July 04, 2018, 07:44:44 pm »
I need a bit more of help, I asked in the mormot forum, if anyone interested
https://synopse.info/forum/viewtopic.php?pid=27640#p27640

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus