Get multiple client data to a web app

Ah ha, we’re getting closer :slight_smile:

But, you’ve only got the one client updating multiple browsers, whereas I’ll have multiple clients (maybe up to 100 or more) and only the ONE browser to show all the client’s data.

Folks,

Can someone guide me to the next step, please?

How do you access Webpage1 from HandleURL event?

I guess I don’t understand the relationship between app, session & webpage.

App represents the whole app, not a connection by a particular user.

Sessions are persistent browser connections. They require that the client actually be a browser.

WebPages are sent to browsers as part of a session.

If you need to get data from App.HandleURL to a particular session, you’ll need to know what the session identifier is or you can send the data to all of the connected browsers.

The way to do this is to put a method on Session… lets say it’s called AddTemperature:

Public Sub AddTemperature(temp as single) WebPage1.TextArea1.text = str(temp) End Sub

Then on the app class you can add a method tell it to send to each of the sessions, thusly:

Public Sub SendTempToSessions(temp as single) for i as integer = 0 to SessionCount - 1 Session(SessionAtIndex(i)).AddTemperature(temp) next End Sub

Thanks, Greg, but without testing it - your code seems to put just the one, newest temperature value into textarea.

To show every temperature, I assume I insert them into defined rows of a listbox?

By the way, my web app was running ok earlier - but suddenly it’s just showing a white, blank page with a security alert (i), warning me to not transact any secret data!
Any idea what’s caused this & how to get around it!?

Thanks

[quote=378845:@Darren Logan]Thanks, Greg, but without testing it - your code seems to put just the one, newest temperature value into textarea.

To show every temperature, I assume I insert them into defined rows of a listbox?[/quote]
I suggest inserting into row zero so the latest data will always be on top.

[quote=378846:@Darren Logan]By the way, my web app was running ok earlier - but suddenly it’s just showing a white, blank page with a security alert (i), warning me to not transact any secret data!
Any idea what’s caused this & how to get around it!?

Thanks[/quote]
Did you switch to ssl?

I don’t recall making any switches, Greg. Where do I look for that?

Fyi: I only have the trial version of xojo so I can’t build or deploy at the moment.

Could you copy and show us the exact text?

[quote=378840:@Greg O’Lone]App represents the whole app, not a connection by a particular user.

Sessions are persistent browser connections. They require that the client actually be a browser.

WebPages are sent to browsers as part of a session.

If you need to get data from App.HandleURL to a particular session, you’ll need to know what the session identifier is or you can send the data to all of the connected browsers.

The way to do this is to put a method on Session… lets say it’s called AddTemperature:

Public Sub AddTemperature(temp as single) WebPage1.TextArea1.text = str(temp) End Sub

Then on the app class you can add a method tell it to send to each of the sessions, thusly:

Public Sub SendTempToSessions(temp as single) for i as integer = 0 to SessionCount - 1 Session(SessionAtIndex(i)).AddTemperature(temp) next End Sub[/quote]

If you do it this way, then you won’t be able to scale up with this web app. If you install several instances of the webapp behind a load balancer like haproxy, each app can only inform its own sessions. So with this approach you’re stuck with one instance only.

If the webapp would write data to a database, then each instance could use a timer, look for a new data flag and then pull data and display it. With this approach you still can respond to a high demand situation and use a load balancer.

Oliver,

I don’t understand what you’re suggesting. I’m too new to web technology & xojo so the lingo is confusing me.

I’m also desperate to keep things simple for now.

Ok, let me explain the scenario in another way:

Let’s say I’m designing a temperature monitoring system.
I have a few hundred sensors spread around a factory & want to get all the temperature readings onto ONE web page.
The sensors are connected to Pc’s (via a serial cable) running desktop apps. The desktop apps are to send the readings to the web app.

How? lol

You can hire someone if you don’t have the time to learn how to use Xojo.

I think we know your goal. It’s just that no one really wants to give you all the code needed, as you will not learn as much if we do :wink:

I’m a bit curious myself at what event is best to use here. HandleSpecialURL or HandleURL?

I understand that sentiment. Totally.

I’ve been a .net developer for decades & always keen to learn but this is a side-project / proof of concept before I offer it as a possible project to my employer. Not the normal project process… more of a “see if it works”.
I’m up to my eyeballs with work at work so the only learn time I get is at home, & that’s not a lot with a family.

With .net, if you get stuck you’re guaranteed to find the answer on the web somewhere & I’m surprised there’s nothing obvious out there to get me of this initial hurdle.
I’ve played around with xojo a little bit & instantly recognised it could be used for the web app in suggesting.
Unfortunately it’s not obvious to the new user.

I can deal with all the display / dB stuff. It’s the communicating over the web I don’t get - at all.

Besides, you say I should be learning myself - which I agree with, but actually there’s a few conflicting suggestions in this conversation. I’m not sure who is giving me the best advice?

I thought Greg had given me the lead a few posts above, but then Oliver has contested it?

This isn’t helping my already confused mind! Lol

[quote=378932:@Darren Logan]Oliver,

I don’t understand what you’re suggesting. I’m too new to web technology & xojo so the lingo is confusing me.

I’m also desperate to keep things simple for now.

Ok, let me explain the scenario in another way:

Let’s say I’m designing a temperature monitoring system.
I have a few hundred sensors spread around a factory & want to get all the temperature readings onto ONE web page.
The sensors are connected to Pc’s (via a serial cable) running desktop apps. The desktop apps are to send the readings to the web app.

How? lol[/quote]
In this case I would let the desktop apps write their sensor data to a server database. Then a web app can pull such data from the database and display it on a webpage in a listbox, for example.

Whenever someone calls this webapp, then it will display the most recent data. The webapp can also refresh the display by itself (web timer).

I don’t think you would need a web service for the scenario you described, although it would work as well.

You simply take the route which is most comfortable to you.

Same difference. The big advantage or HandleURL is that you can use as many virtual directories as you want, which makes it very flexible.

I know what you mean :wink:

I could create a somewhat working example for you that reads the posted data and pushes it to all sessions(as per my video) without error checking and stuff, so you need to learn that? But, family and all that so I don’t know when i’ll get the time for it really :wink:

Albin,

I’m not sure whether you’re being sarcastic or not there but hopefully you have some understanding.

I was hoping for a quick response to get me going with a concept.

Oliver - is a dB, categorically the only way to go?
Is there no way of doing this without a dB?

If I understand correctly, a new session is created on each connection.
Now, it appears that it is possible to put the url parameters onto the web page, so why isn’t it possible to put multiple session url parameters onto the same page? I don’t get that bit.
At least one post above suggests you can. So who’s right?

I didn’t want to use a dB because I was hoping for a very simple solution with minimal installation / configuration - an obvious wish.
I’ve implemented a MySQL server on a few occasions so I know the amount of installation/ setup required. You also have to pay for it if for commercial use.

Sqlite is local only, isn’t it? No good for this? Similar to MS SQL Local dB.

Darren