B4J Question GetVal.Value - Waiting for value

ilan

Expert
Licensed User
Longtime User
hi

i use WebSocket in my b4j web app and i get a lot of "Waiting for value (110 ms)" in the logs and i wonder if i am doing something wrong?

i have a form and i am getting the data from the Textfields via JQueryElement. i could use a form-post request instead. is that the better approach?
or can i still use JQueryElements and get the data via GetVal.Value but avoid too many "Waiting for value (110 ms)" logs?

this is how my logs look like:

 

ilan

Expert
Licensed User
Longtime User
actually, this is the jqueryElement click event:

B4X:
Sub sigupBtn_Click (Params As Map)
    Dim userN As String = su_user.GetVal.Value
    Dim userP As String = su_pass.GetVal.Value
    Dim userE As String = su_email.GetVal.Value

    '.....
End Sub

i saw that also in your guess my number _ws example there is a delay when you call .GetVal.Value like something is refreshed in the background.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
This code is exactly how you shouldn't get the values.

See the network latency section: https://www.b4x.com/android/forum/threads/webapp-hello-world-web-app.39808/#content

ok, I had a look at the thread. did not understand everything but will read it again.

anyway, i assumed that this is the way to do it since it is in the guessmynumber_ws example:



but after changing to this:

B4X:
    Dim ft1 As Future = su_user.GetVal
    Dim ft2 As Future = su_pass.GetVal
    Dim ft3 As Future = su_email.GetVal
    Dim ft4 As Future = su_fname.GetVal
    Dim ft5 As Future = su_lname.GetVal
    
    Dim userN As String = ft1.Value
    Dim userP As String = ft2.Value
    Dim userE As String = ft3.Value
    Dim firstN As String = ft4.Value
    Dim lastN As String = ft5.Value   
    
    Log(userN)
    Log(userP)
    Log(userE)
    Log(firstN)
    Log(lastN)

i get only 1 time Waiting for value (114 ms) what makes it much much faster now. i don't understand why but if it works i won't ask to many questions
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
i don't understand why but if it works i won't ask to many questions

ok understand now

The correct design is quite simple. When the event starts you need to get all the future values that later are needed.
Only then you should call Future.Value. This allows you to get all the values in a single round trip (Server -> Client -> Server).
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…