Martybartfast 1 Posted May 24, 2022 I'm using ICS Web Sockets, and everything is working good so far - browsers connect to my server, and the ICS "echo" sample works fine. However, I need to send an unsolicited string from the server to all connected clients. Anyone know how to do this? I've tried and tried, and can't find any way to access the web socket clients. If I just do "Webserver.client[n].sendstr(s);" then the browser just disconnects. What I'm trying to do this something like this: WebSocketServer: TWSocketServer; ... procedure THttpGUI.Start; begin ... if not(assigned(WebSocketServer)) then // Don't do if already created begin WebSocketServer := TWSocketServer.Create(nil); // Create the WebSocket server WebSocketServer.Proto := 'tcp'; // TCP/IP protocol WebSocketServer.ClientClass := TWebSockSrvClient; // Web socket WebSocketServer.Banner := ''; // Remove banner because we handle websocket handshake WebSocketServer.OnBgException := WebSocketServer_BgException; WebSocketServer.OnClientConnect := WebSocketServer_ClientConnect; WebSocketServer.OnClientDisconnect := WebSocketServer_ClientDisconnect; end; end; // Connection stuff all works fine, not shown here ... // Send a string to all connected clients (browsers). procedure THttpGUI.WebSocket_SendString(s : string); var n : integer; begin if assigned(WebSocketServer) then begin for n := 0 to WebSocketServer.ClientCount-1 do begin WebSocketClient[n].sendString(s); // Something like this!!! end; end; end; Share this post Link to post
Remy Lebeau 1436 Posted May 24, 2022 2 hours ago, Martybartfast said: I'm using ICS Web Sockets You do know that you posted this in a VCL forum, right? ICS has its own forum on this site: https://en.delphipraxis.net/forum/37-ics-internet-component-suite/ Share this post Link to post
Angus Robertson 577 Posted May 24, 2022 He originally posted the question in the ICS forum, but the issue is not with ICS, but with a Javascript web page implementation to display data from the websockets server. Angus Share this post Link to post