B4J Question Wait for something to process before continuing

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I am using a Class Module within my B4J app and from the WebSocket module I have Initialize the class.

In this class module I am using a SOAP message request which will send the message off and in the JobDone sub I am getting the reply. Which is all working fine.

The part I need help with is..

From my WebSocket Module I want to know if the value that is returned from the SOAP message equals something before the code continues in a sub.

For Example:
I am sending a SOAP message to request if a user exists on the server.
The reply I should get back either yes or no (which I have working.)

From my code I want to check what that value is before continuing in that sub.

e.g:
B4A/B4i (or even my webpage with the websocket) sends a WebSocket request to my B4J app and asks "does user abc exist on the 3rd Party server"
The B4J needs to send a SOAP message to a 3rd Party server and check if the user exists on the server.

(I need to check if the user exists from the B4J app and not the B4A/B4i app.)

IF the reply from SOAP Message = "yes" Then
' send message to the B4A/B4i app and send "yes"
End If
 

aaronk

Well-Known Member
Licensed User
Longtime User
1. Send the request.
2. Call StartMessageLoop.
3. In JobDone call StopMessageLoop.

Shouldn't it be the other way around?

Like:
Call StartMessageLoop in Main Module:
B4X:
Sub AppStart (Args() As String)
    StartMessageLoop
End Sub

Webpages on my server is running and loading etc.

User then requests if the user is valid..

1. Send the SOAP request - call StopMessageLoop
(by the way, at this point what happens if another user tries to view files on my server, does it mean nothing will load until StartMessageLoop is called?)

2. In JobDone call StartMessageLoop.

Do I have the above correct ?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Shouldn't it be the other way around?
No.

You should send the request and then call StartMessageLoop. The code after the StartMessageLoop call will only run after StopMessageLoop has been called.

(by the way, at this point what happens if another user tries to view files on my server, does it mean nothing will load until StartMessageLoop is called?)
No. It only blocks the current thread. Each request is handled by a different thread.
 
Upvote 0
Top