I try to send a job to the server. After that, the server loads the needed resourcces from another server and send the result back to the response stream of the client. The problem is, that the job is mostly success before the response stream is available, so job.getstring is emty. Is it possible that the client could wait on the positive result of the response?
B4X:
'Client-Code:
Dim Job As HttpJob
Job.Initialize("kg", Me)
Job.Tag=Fremdserver
Job.PostString(ServerPfad & "&type=kg" & ......)
Sub JobDone (job As HttpJob)
Select job.JobName
Case "kg"
If Job.Success Then Log(Job.getstring)
...
End Sub
'Server-Code:
Sub Handle(req As ServletRequest, resp As ServletResponse)
Dim In As InputStream = req.InputStream
Dim reqType As String = req.GetParameter("type")
...
Select reqType
Case "kg"
Dim tr As TextReader
tr.Initialize(In)
Dim Standort As String = tr.ReadAll
Dim rs As ResumableSub = KG_Fremdserver_downloaden("Test", "Test"))
Wait For(rs) Complete (Result As String)
resp.Write(Result) '<---------- result to the client
...
...
End Sub
Private Sub KG_Fremdserver_downloaden(Standort As String, konferenzname As String) As ResumableSub
Dim AnyString As String=""
Dim KGFremdserver As HttpJob
KGFremdserver.Initialize("", Me)
Dim url As String = serverpfad & "/" .....
KGFremdserver.Download2(url, Array As String("...."))
Wait For (KGFremdserver) JobDone (KGFremdserver As HttpJob)
KGFremdserver.Release
If KGFremdserver.Success Then
...
....
Return AnyString
End If
Return AnyString
End Sub
Last edited: