I am using Xojo.Net.HttpSocket in order to Communicate with a Json API.
I have created a subclass of Xojo.Net.HTTPSocket named fUpdate that implements all the Event Handlers (PageReceived,HeadersReceived)
The code in these Events just writes a text in the log file of the app and also has break.
I call this Socket using a subclass of a Thread named thUpdate that has the following code in its Run Event:
Dim info as new xojo.Core.Dictionary
ivSocket = new ForkyUpdate
ivSocket.id = id
select case state
info.Value("status") = "cancelled"
info.Value("status") = "downloaded"
info.Value("status") = "printed"
info.Value("status") = "assigned"
info.Value("status") = "delivered"
Dim json as text
json = Xojo.Data.GenerateJSON(info)
Dim data as xojo.Core.MemoryBlock = Xojo.Core.TextEncoding.UTF8.ConvertTextToData(json)
Dim lvS as String ="AUTHENTICATIONSCRIPTISHERE"
ivSocket.RequestHeader("Authorization") = lvS.ToText
ivSocket.RequestHeader("Content-type") = "application/json"
With this way I never receive anything in the Socket Events.
If I add the Socket in my Window and call the same method without the use of a thread i receive the events but when I try to use the Socket of
the window's controls more than i one time i receive the error : a request is already in progress.
I must have a check in the event in order to see that the API answer me correctly or not in order to deal with it.
Do you have any suggestions? Is there something am I doing wrong?
Thank you in advance.