Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multipage websocket communication
#1
I've a Delphi 12 VCL app that I'm using Intraweb and sgcWebsockets to develop a web page based remote control for. Use a browser to control the app as you would as if you were at the computer sort of thing. To make the web pages nice for iPhones and such, it requires 2 pages. I put a websocket server in the VCL app and a client on the first page of the Intraweb app. Works great. Buttons work, data flows back and forth. The problem comes when the web app is switched to the second page. The client on the first page disconnects. Adding a second client to the second page doesn't connect either. Tried adding a second server with diffferent port numbers on the VCL without success. I'm using the two page design outlined in the Intraweb 15 example "MultiPageAPP". How can I get both pages to 'talk'?
Reply
#2
(03-08-2024, 09:31 PM)davidbaxter Wrote: I've a Delphi 12 VCL app that I'm using Intraweb and sgcWebsockets to develop a web page based remote control for. Use a browser to control the app as you would as if you were at the computer sort of thing. To make the web pages nice for iPhones and such, it requires 2 pages. I put a websocket server in the VCL app and a client on the first page of the Intraweb app. Works great. Buttons work, data flows back and forth. The problem comes when the web app is switched to the second page. The client on the first page disconnects. Adding a second client to the second page doesn't connect either. Tried adding a second server with diffferent port numbers on the VCL without success. I'm using the two page design outlined in the Intraweb 15 example "MultiPageAPP". How can I get both pages to 'talk'?

Try putting the Web Socket in the UserSession
Reply
#3
It's not allowed, unfortunately.
Reply
#4
I would need to have a better description of this design or, even better, a small test case showing the issue. Hard to tell with this limited information.
Reply
#5
Thank you, Alexandre. I'm not ignoring you, but trying hard to solve the situation myself. I changed the design from using two IW forms to a single form with a tabbed control on one form to switch between views. Communications still drop out when I change tabs. To summarize the design, it starts with a normal Delphi application that has a grid of rows to select and some start and stop buttons. Using Intraweb and the sgcWebSockets components, I'm trying to build a "remote control" web application to allow a web page to select rows and push the buttons. It all works very well as long as there is only one page/tab on the IW app. When I try to change the screen on the IW app, communication to the main exe is lost. As an example, here is a log of the "conversation" between the two applications. The main exe is WS... and the IW app is Send and In.

00:02:01.777 - WSConnected 2969 ( I start the web page and do a socket1.open, the main exe says it's connected)
00:02:01.794 - Clnt connect (the web page app says it's connected too)
00:02:02.048 - Send load (and sends a request for some data)
00:02:02.052 - WSRcvd: load (the main exe receives the request)
00:02:02.067 - In 3|2|S2|playlist.m3u|4|S4|Bells||| (and sends back the data, delimited by |)
00:02:14.490 - Send goto 2 (the main exe has a grid on it, we ask to click line 2)
00:02:14.495 - WSRcvd: goto 2 (the main exe gets the ask)
00:02:14.503 - In next0 (and sends back a message for the web app to go to the same line)
00:02:25.865 - Send play (the main exe has a list of songs, we selected #2 before and now we play it)
00:02:25.870 - WSRcvd: play (the main exe gets the play request and does it)
00:03:00.463 - Send fade ( we want to fade out that song)
00:03:00.468 - WSRcvd: fade (main exe acknowledges and tells the web app to advance to the next line)
00:03:04.941 - In next1 (web app gets that request)

Now we switch to the second tab on the IW web app page, no indication of a disconnect
00:03:31.783 - Send lback (so the web app sends a message from a button click on the second tab page)

No response the main exe that it's listening, and nothing happens at the main exe
00:04:40.795 - Send goto 2 (so we go back to the first tab and ask again to click line 2, nothing happens, we've lost communication without any sign of loss from either end)

Somehow in my research and trials, I've missed the correct design of an IW app that maintains websocket communication across 2 pages or tabs. I'm also checking with the Experts Exchange folks to see if anyone there has a suggestion.
Reply
#6
Coming up with a short demo, I discovered the issue. In porting an application from D11 to D12, I entered a procedure for OnClick instead of OnAsyncclick. It seems that if you have just one button set for OnClick, it stops everything when shown, whether you actually click that button or not. Making sure all buttons have only OnAsyncClick procedures has fixed the issue.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)