I am totally confused. I have created a Class in a JettyServer application that makes requests to an on line REST API. I used this code:
B4X:
Dim sURL As String = "https://myapi.com/v2/setvalue"
Log(sURL)
hj.PostString(sURL, sRequestJSON)
hj.GetRequest.SetHeader("Authorization", sBearer)
hj.GetRequest.SetContentType("application/json")
Log("-2-")
wait for (hj) JobDone (hj As HttpJob)
Log($"Status Check ${hj.Response.StatusCode}"$)
sResp = ""
The problem is it works perfect. Then I noticed that I did not need the StartMessageLoop and StopMessageLoop in response. The class is called from a WebSockets class. Is it normal behaviour or I have done something strange? The code is executed on a button click.
No, I do not use jServer in a UI app. What I said is that the HttpJob with "wait for" worked as it was supposed to work in a UI app. I was confused because normally I would use StartMessageLoop and StopMessageLoop. @EnriqueGonzalez has made clear to me that in a web socket we can use the HttpJob with wait for (hj) JobDone(hj as HttpJob) without the need of StartMessageLoop, StopMessageLoop.
@EnriqueGonzalez has made clear to me that in a web socket we can use the HttpJob with wait for (hj) JobDone(hj as HttpJob) without the need of StartMessageLoop, StopMessageLoop.
No, I do not use jServer in a UI app. What I said is that the HttpJob with "wait for" worked as it was supposed to work in a UI app. I was confused because normally I would use StartMessageLoop and StopMessageLoop. @EnriqueGonzalez has made clear to me that in a web socket we can use the HttpJob with wait for (hj) JobDone(hj as HttpJob) without the need of StartMessageLoop, StopMessageLoop.
the main idea is that handlers in the server won't wait until the http job finishes, this behavour happens too with non ui apps in the main module because UI apps have an "event loop" integrated.