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.
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.
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).
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
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!
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
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.
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?
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.
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
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.
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.
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…