PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WEBDEV 2024 → Coomunication beetwen pages
Coomunication beetwen pages
Started by Mimmo Ghiara, Feb., 24 2020 4:58 PM - 8 replies
Posted on February, 24 2020 - 4:58 PM
Hello to all
I have a problem like this
I have to manage two users who need to interact. I'll explain
User 1: starts a procedure which must wait for user 2 to intervene and modify a record.
Once this is done, user 1 checks that the record is modified and must launch a second procedure and communicate to user 2 who has launched this procedure.
It happens that if I keep user 2 on hold with a loop or similar, user 1 also remains on hold and the second procedure does not start until user 2 has exited the loop.
I cannot use the asynchronous methods available only to the browser as I have to make two queries.
Is there no system to communicate between web clients?
Do you have any suggestions?
Thank you
Mimmo
Posted on February, 24 2020 - 10:16 PM
I have to manage two users who need to interact. I'll explain
User 1: starts a procedure which must wait for user 2 to intervene and modify a record.
Once this is done, user 1 checks that the record is modified and must launch a second procedure and communicate to user 2 who has launched this procedure.


> It happens that if I keep user 2 on hold with a loop or similar, user 1 also remains on hold and the second procedure does not start until user 2 has exited the loop.

That is not true... no user session has any impact on another user session. You must be testing with both user being in fact 2 pages in the same browser, and badly, as in using the same session.


I cannot use the asynchronous methods available only to the browser as I have to make two queries.

That is not true either. Yo can use ajaxexecute or ajaxexecuteasynchronous FROM the browser and run the queries in the server procedure called by them...


> Is there no system to communicate between web clients?
Directly no... but each with the server, easily.

Do you have any suggestions?


Timer on each side to wawit for the other, ajax (synchronous or not) to call the server, and you are done
Posted on February, 25 2020 - 2:45 PM
I also tried this way by calling the timers with two different variables and different procedures, but until the second one finished the first one remained still
Tested between two computers on the same network and the server is a virtual server

Thanh's
Posted on February, 25 2020 - 2:55 PM
Maybe I didn't say one thing that the second browser writes a record and waits for im first to pass a field from false to true, and the first browser does not put true until it sees the requested record
More or less both remain in loop

Mimmo
Posted on February, 25 2020 - 4:21 PM
> Timer on each side to wawit for the other, ajax (synchronous or not) to call the server, and you are done

That IS the correct way... If your system doesn't work doing just that, then your code is incorrect.
Posted on February, 27 2020 - 6:14 PM
I agree but I can't understand where the code is wrong
I hope you can help me

There are two buttons on the page
Player 1 and Player 2
Player 1 must choose a team and press the player 1 button which starts a timer waiting for player 2

A GAME record is recorded where teams are presnete and a "Player 1 in game" field that is boolean and becomes true when Player 1 presses his button and starts the game

Player 2 must see that Player 1's team is present, choose his own team and press Player 2.
When Player 2 presses the button, Player 1 appears the "PLAY" button
When "Play" the "Player 1 in game" field is pressed, Player two must have his "Play" button displayed.
ERROR: At Player 2 the button is not displayed and cannot play in turn.

Let's move on to the code

PLAYER 1 button (onclick browser)

gtOraini = Now ()
gnTimer1 = Timer (Difference, -100)
IF gnTimer1> 18000 THEN
EndTimer (gnTimer1)
END

--------
PROCEDURES Difference
nDiff is real
Res1 is numeric
Res2 is string

ndiff = TimeDifference (gtOraini, Now ())
CTL_TIME2 = nDiff (View wait)
Res1 = AJAXExecute (ajaxUpdateControls, refresh_p)
IF Res1 <> 0 THEN
EndTimer (gnTimer1)
Res2 = AJAXExecute (ajaxUpdateControls, xmldoc, Res1)
END
---
PROCEDURES refresh_p
executes a query to check that PLAYER 2 has chosen the team and pressed his button.
If the query is positive then activate the PLAY button
----------------------------------------------



PLAYER 2 button (onclick browser)

gtOraini2 = Now ()
gnTimer5 = Timer (Difference_peer, -100)
IF (gnTimer5> 2000) THEN
EndTimer (gnTimer5)
END
-----

PROCEDURES Difference_peer

nDiffpeer is in
SRes1 is numeric = 0
sRes2 is string
nSRes3 is int

nDiffpeer = TimeDifference (gtOraini2, TimeSys ())

CTL_TIME3 = nDiffpeer

SRes1 = AJAXExecute (ajaxUpdateControls, refresh_p1)
-----------

PROCEDURES refresh_p1

He has to look for the game and see if "Player 1 in game" has become true
Puts Button for PLAYER 2 to start the game

-------
This button is never displayed
It seems that the first Timer waits for the second to end, then puts the button but when PLAYER 1 takes it, the second Timer seems to be gone

I understand that it is very difficult to understand everything
But if anyone has any suggestions, welcome
Thank you
Mimmo
Posted on February, 28 2020 - 7:41 AM
I don't have the time to go through all your code, create a project to insert it in, and test it in the debugger, which is the only way to see what's going on in a case like that...

So I would suggest that you find yourself a consultant and pay him/her to do that with you... I'm using Fabrice Harari when I have a problem I can't find, he helped me a LOT in the past.
Posted on February, 28 2020 - 12:47 PM
Thank's

Mimmo
Posted on March, 11 2020 - 8:33 AM
Use serverside events ( SSE ) A timer is a bad way Of doing stuff.