B4J Question [Solved] Is posible to call AsyncStreamsText with Wait For?

Gabino A. de la Gala

Well-Known Member
Licensed User
Longtime User
Possibly I need to send several "simultaneous" requests to the server and then I would need to know the response of this to each of them. The problem that the server is not "mine" and only responds with an Ok. With which I have no way of knowing which one he really responded to.

I guess I would have to do it with some kind of queue and always send one at a time and wait for the server to respond to send the next one.

But with the wait for I think I could solve it easily. Hence my question.
 

josejad

Expert
Licensed User
Longtime User
Maybe this example could help you with something similar?

The " How to download a list of resources, one by one " part

 
Upvote 0

Gabino A. de la Gala

Well-Known Member
Licensed User
Longtime User
Maybe this example could help you with something similar?

The " How to download a list of resources, one by one " part


I'm trying like this:
B4X:
Sub EnviarComando2(Comando As String)
    Dim astAux As AsyncStreamsText
    Try
        Log("Enviando Comando2: " & Comando)
        astAux.Initialize(Me, "", socketIn.InputStream, socketIn.OutputStream) 'initialize AsyncStreamsText with the socket streams.
        astAux.Write(Comando & Chr(13) & Chr(10))
        Wait For (astAux) EventName_NewText (Text As String)
        Log("Enviado Comando2: " & Comando)
    Catch
        Log("Enviar Comando2: " & Comando & LastException.Message)
    End Try
End Sub

The write does it correctly, since in the server log I see that it receives it.

But it never "returns" from the wait for.

Is it a problem with the name of the event or something like that?
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Upvote 0
Top