Get multiple client data to a web app

Hi all,

I’m brand new to xojo.

I’d like to design a system where multiple Windows clients (up to around 100) can communicate their string (JSON) data to a standalone xojo web app.

The clients will need to send between 10 & 200 bytes at roughly once every 10 seconds.

The web app will show all client data on the page.

My question is:
What methods can I use to get the clients data to the web app?
Server socket in the web app? Shared database?
I’d prefer a socket/tcp method to avoid the complexity of a dB.

Any pointers greatly appreciated!
Thanks
Darren

Hi and welcome.

We’re a small community. Someone will answer you when they get the chance. Please don’t double post within the hour, that’s kind of rude.

I can give you my welcome spiel if you want it, but it starts with: read the manual, don’t jump in to a project.

There should be some examples for web applications, also on the documentation.xojo.com pages you might be able to find alot about Web Topics.

A web application has events you might add using the IDE, named:
App.HandleURL and App.HandleSpecialURL
They both provide Request As WebRequest as a parameter.

In the event you can use it to read the incoming (HTTP) data, which might be JSON.
This is actually a HTTP Server, as a backend, ideal for your purpose.

Xojo Web Reference
Xojo WebApplication Class Reference
There you can see the events and read more about it.

It’s best to use App.HandleSpecialURL which you can call like so: 127.0.0.1:8080/api/ or 127.0.0.1:8080/special/
when your using the debugger (Run button).

Hi Derk & Tim,

Tim - thanks for the welcome.
I started looking at Xojo about a week ago because I wanted to branch out from .net and broaden my developer horizons, so to speak.

Apologies for the double post. I posted in “getting started” and only after thought that it may be more beneficial to post in web. This is my first appearance on this forum :slight_smile:

I’m a desktop man and have very little web experience, so please excuse any silly questions.

I completely understand your sentiment behind “read the manual before jumping in”, but please note that I have been doing a LOT of reading over the past week but find myself going round in circles because of all the web terminology I’m not familiar with.
Web API, REST, Web service, Server Sockets, TCP sockets, etc. - words tumbling around in my head preventing me from actually extracting the info. I need.
It appears that there are several ways to do what I want, but choosing the right one is very difficult at this stage.

I want to get a simple demo. up and running, with several clients sending their string info. (in JSON for example) packets to a Xojo web app. over a company LAN, and the web app crudely displaying that data in a text field, for example.
Client data is typically 10 to 100 bytes long and will be sent about once every 10 seconds from each client.
How does the web app. handle the randomly arriving packets from each client, without contention or clashing/loss of data? I assume automatically and reliably by the received event and that you don’t have to worry too much about the traffic handling aspect of it?

Derk - thanks for the pointer. I’ll take a look at HandleURL/SpecialURL. I’ve already read about this but I wasn’t confident enough to realise it would be viable for me. Maybe this is the answer I’m looking for!

Thank you
Darren

[quote=378467:@Darren Logan]Hi Derk & Tim,

Tim - thanks for the welcome.
I started looking at Xojo about a week ago because I wanted to branch out from .net and broaden my developer horizons, so to speak.

Apologies for the double post. I posted in “getting started” and only after thought that it may be more beneficial to post in web. This is my first appearance on this forum :slight_smile:

I’m a desktop man and have very little web experience, so please excuse any silly questions.

I completely understand your sentiment behind “read the manual before jumping in”, but please note that I have been doing a LOT of reading over the past week but find myself going round in circles because of all the web terminology I’m not familiar with.
Web API, REST, Web service, Server Sockets, TCP sockets, etc. - words tumbling around in my head preventing me from actually extracting the info. I need.
It appears that there are several ways to do what I want, but choosing the right one is very difficult at this stage.

I want to get a simple demo. up and running, with several clients sending their string info. (in JSON for example) packets to a Xojo web app. over a company LAN, and the web app crudely displaying that data in a text field, for example.
Client data is typically 10 to 100 bytes long and will be sent about once every 10 seconds from each client.
How does the web app. handle the randomly arriving packets from each client, without contention or clashing/loss of data? I assume automatically and reliably by the received event and that you don’t have to worry too much about the traffic handling aspect of it?

Derk - thanks for the pointer. I’ll take a look at HandleURL/SpecialURL. I’ve already read about this but I wasn’t confident enough to realise it would be viable for me. Maybe this is the answer I’m looking for!

Thank you
Darren[/quote]

Don’t forget to “Return True” if you handled the Request using App.HandleSpecialURL or App.HandleURL.

Hi folks,

Sorry, just to clarify:

My web app is to display the data of all clients to all clients.

The handleurl examples I’ve seen are for showing a different page according to the url path. I don’t want that.

Each client will send say, a temperature reading to web app. The web app must display all client temperature readings on one page (in a list for example).
Do I still use the handleurl method for this?

Thanks
Darren

You would want your desktop app connecting to a Web App with handleurl or handlespecialurl enabled to upload the data. That data would be recorded to a table in a database. Like Sqlite. Then you would have a page in your Web App that would display the contents of that table on the page.

We do something similar with having Ipads uploading data through handlespecialurl to our web app. Then that information can be displayed in a table on a page.

I see now you were wanting to avoid using a db. If its data that does not need to be retained. You could just create an array in App that would hold the data and just keep adding to it. You would need it to be in App so that all Sessions could see it. You would need to address clearing that array before you run out of memory.

Hi Steve,

Thanks for your post.

I’ll be fine with storing/displaying the data once I’ve got it, my problem is how to get it!
I’m new to web applications so it’s a new field for me.

I’ll try & knock something basic up shortly using handleurl.

Thanks again

Darren

Hi all,

I spent a couple of hours last night trying to get this to work but to no avail.

Client was a vb.net desktop app sending a webrequest with properly formatted url & one parameter.

Web app handle url event was firing but even trying a few samples on here I could not extract that parameter & display it in a text field.

All running on the same win 10 laptop.

Could someone please give me the code to extract the param & send it to a text field?

Eventually, there could be many 10’s of different clients sending data. They must all be displayed in the same text box.

Thank you
Darren

You can download a zip file with two sample projects, a webservice and a client application, which communicate with JSON, from here: http://www.seminar.pro/koblenz16

You can run the myservice.xojo_binary_project locally and once it has opened a browser (http://127.0.0.1:8080) you can run the client project (serviceClient.xojo_binary_project), hit the “Local” button and then the “Send” button.

The result should look something like this:

P.S: The client is using the MBS Util Plugin. For testing you can comment out the MBS lines and hardcode a result, or download the plugins

[quote=378667:@Darren Logan]Hi all,

I spent a couple of hours last night trying to get this to work but to no avail.

Client was a vb.net desktop app sending a webrequest with properly formatted url & one parameter.

Web app handle url event was firing but even trying a few samples on here I could not extract that parameter & display it in a text field.

All running on the same win 10 laptop.

Could someone please give me the code to extract the param & send it to a text field?

Eventually, there could be many 10’s of different clients sending data. They must all be displayed in the same text box.

Thank you
Darren[/quote]
Please show the url you are sending and the code you are using to process it in the web app.

Sending this every 5 seconds from a vb.net client app:

Dim myRequest As WebRequest = WebRequest.Create("http://localhost:8080/?Temperature=" & val.ToString)

Val is a temperature value of type Single.

The xojo web app code is probably nonsense. I can’t seem to find anything that relates to what I want.
In the HandleURL app. event is this:

If Session.Available Then
  
  If session.URLParameterCount > 0 Then
    Dim parameterName, value As String
    For i As Integer = 0 To session.URLParameterCount - 1
      parameterName = session.URLParameterName(i)
      value = session.URLParameter(parameterName)
      WebPage1.TextArea1.AppendText(parameterName + " = " + value + EndOfLine)
    Next
  End If
end if

I think the handleUrl event is fired but session is NiL and caused an error.
I really haven’t a clue where to start because this type of communication is totally new to me.

Thanks
Darren

HandleURL does not use a Session, so it will always be Nil.

Use the parameter Request As WebRequest that is part of HandleURL to check the query string.

Hi,

That causes a bug at line Dim Query…

The event is fired but it halts at line Dim Query as String… with a bug icon next to it!

By the way, I’m not using the vb app. anymore during this initial stage. I’m just typing the url in another browser window and pressing ENTER.

Oops, sorry. I made a mistake.

OK, that simple code is working.

Now, how do I get that QueryString onto Webpage1.TextArea ?

This is an example I created. Is it something like this you’re creating?
It uses HandleSpecialURL to receive the value and pushes it to all available sessions and displays it on the page.

https://youtu.be/oKK3K1CnH0k

Hi Albin,

Are the values appearing in web browsers or desktop apps? I can’t tell because they’re MAC windows!? lol

If the values are appearing in web browsers then yes - exactly what I want!!!

They are browser windows.
But, Paul is suggesting HandleURL. I don’t know what’s best for this type of application. HandleSpecialURL or HandleURL?
This example is HandleSpecialURL…