I have read in another thread how to manage this, but something is not working properly.
In my situation I need to give a response.write not after downloading a file but after a RDC connection to a remote server.
So I have this in the server handler:
And this is the sub:
This way the server hangs and then timeout with an error.
If I remove StarMessageLoop and StopMessageLoop looks like is ok server side, but the resp.write sometimes does not arrive in time to the client.
Where I'm wrong ?
I'm using jOkHttpUtils2_NONUI library
In my situation I need to give a response.write not after downloading a file but after a RDC connection to a remote server.
So I have this in the server handler:
B4X:
Sub Handle(req As ServletRequest, resp As ServletResponse)
QueryUserFromRemoteServer(resp, "user001"))
StartMessageLoop
End Sub
And this is the sub:
B4X:
Sub QueryUserFromRemoteServer(resp As ServletResponse, user As String)
Dim dbcmd As DBCommand
dbcmd.Initialize
dbcmd.Name = "QueryUser"
dbcmd.Parameters=Array As Object(user)
If dbreq.IsInitialized=False Then dbreq.Initialize(Me, "http://" & RemoteServer & ":" & RemotePort & "/rdc")
dbreq.ExecuteQuery(dbcmd, 0, "tagQueryUser")
wait for JobDone(j As HttpJob)
If J.Success = True Then
Dim result As DBResult = dbreq.HandleJob(J)
For Each records() As Object In result.Rows
If records(result.columns.Get("Authorized"))=True Then
resp.Write("OK")
Else
resp.Write("UnAuthorized")
End If
Exit
Next
Else
Log("Error in query user")
End If
j.Release
StopMessageLoop
End Sub
This way the server hangs and then timeout with an error.
If I remove StarMessageLoop and StopMessageLoop looks like is ok server side, but the resp.write sometimes does not arrive in time to the client.
Where I'm wrong ?
I'm using jOkHttpUtils2_NONUI library