Hello Everyone,
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:
[i] Dim info as new xojo.Core.Dictionary
ivSocket = new ForkyUpdate
ivSocket.id = id
select case state
case 0
info.Value(“status”) = “cancelled”
case 1
info.Value(“status”) = “downloaded”
case 2
info.Value(“status”) = “printed”
case 3
info.Value(“status”) = “assigned”
case 4
info.Value(“status”) = “delivered”
end select
Dim json as text
json = Xojo.Data.GenerateJSON(info)
Dim data as xojo.Core.MemoryBlock = Xojo.Core.TextEncoding.UTF8.ConvertTextToData(json)
ivSocket.SetRequestContent(data,“application/json”)
Dim lvS as String =“AUTHENTICATIONSCRIPTISHERE”
ivSocket.RequestHeader(“Authorization”) = lvS.ToText
ivSocket.RequestHeader(“Content-type”) = “application/json”
ivSocket.Send(“PATCH”,App.forkyUrl.ToText+id.toString.ToText) //DEV[/i]
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.