Get multiple client data to a web app

There is very little you have to do. I just threw this together quickly, but it seems to work fine:

In a web project, this code in App.Handle URL adds temps sent to the web app to an array property (Temps) on the App:

[code]// No real error checking here…
Dim query As String = Request.QueryString
If query <> “” Then
Dim values() As String = query.Split("=")

// Add the temp part of the query
Temps.Append(values(1))
Return True
End If[/code]

On WebPage1, I added a ListBox and put this code in the Shown event:

[code]Me.DeleteAllRows

For i As Integer = 0 To App.Temps.UBound
Me.AddRow(App.Temps(i))
Next[/code]

When the page is reloaded, it will populate it with the temps adds to the array from above.

If you run that web app right from Xojo, you then can submit temps to it using a URL like this:

http://127.0.0.1:8080/?Temperature=77

Just go to another tab and enter that URL. Go back to the web app tab and refresh it to show the new temp in the ListBox. You can also just use that URL to send temps directly using a socket from .NET, Xojo or anything else (such as Paw).

That’s all there is. Obviously this is just a rough sample and you’d want to improve it quite a bit for real use, but this should show you the technique and how simple it is with Xojo.

[quote=378965:@Darren Logan]Albin,

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

Sorry. I have a 1 year old my self, so I certainly understand. Weekend nights are my Xojo time :wink:

A 5 & a 10 year old myself! Toys all over the house!

Right, Paul, thank you!
That works, but you know what my next question is going to be, don’t you?

Yes, the nasty “refresh”.
Is there a way to show the values “live”, without the need to refresh? (like with AJAX)

Can I update somehow in a timer tick?

Answered my own question.

YES, a timer works!

Paul - thank you. This has got the ball rolling.

[quote=378965:@Darren Logan]…

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

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[/quote]

If you do not store the sensor data in one or other way, then you still can send it to a open webpage and append each data record to a list, but when the page shuts down, that data is lost.

SQLite is single user, but if the client apps send their sensor data to a webapp (instead of directly writing to a server database), then the webapp could simply use a SQLite database for storage.

Otherwise you can use Postgres which is a free, opensource , powerful database server.

A webapp could do both at the same time, being a webservice which receives data from the client apps and store it in a database AND being a web server which selects data from the database and displays it on a webpage.

If you chose to go with Postgres, then you can drop the web service part and use the webapp only as web server.

Btw, I agree: MySQL is a no-go because of the Oracle licensing mess.

Hi Oliver,

Ah, OK. Yes, I understand the benefits of a dB, but I prefer to omit it for the time being while I get to grips with the basics of Xojo web, and indeed web technology in general.
I’m too used to .net WinForms!

We’ve only ever used MySQL in-house - which is free, however I understand that commercial licensing is a nightmare and relatively expensive.

I’ll look at Postgres when I can - thanks for the lead.

Btw, I found MS SQL Local dB a bit of pain to setup on my dev. machine. My employer urges us to use Microsoft technology but actually, when it comes to dB’s, I’d rather not - purely for the setup/configuring/maintenance aspect of it. Hey-ho.
MySQL just worked out the box.
Had a quick look at SQlite a few weeks ago and this was straightforward to implement. I like it but shame it’s local only.