You are not logged in.
in mormot.net.ws.client,
if we get a THttpClientWebSockets instance by THttpClientWebSockets.WebSocketsConnect(a static class procudre),
then THttpClientWebSockets.Create never get executed ,
becase THttpClientWebSockets.WebSocketsConnect use Open method to create a socket ,
so the Settings^.OnClientConnected wont take effect (no chance to set this before a connection);
Offline
Open() calls Create():
constructor TCrtSocket.Open(const aServer, aPort: RawUtf8;
aLayer: TNetLayer; aTimeOut: cardinal; aTLS: boolean;
aTLSContext: PNetTlsContext; aTunnel: PUri);
begin
Create(aTimeOut); // default read timeout is 10 seconds
// copy the input parameters before OpenBind()
....
And in fact, THttpClientWebSockets.Create is properly called.
Easy to reproduce with TPrivateRelay.TryConnect called from regression tests.
So I don't understand your problem.
Offline
FClient :=THttpClientWebSockets.WebSocketsConnect(....),
use such code to create a ws client , if connection was made , the "FClient.Settings^.OnClientConnected" callback will be called (if not nil)
BUT, FClient.Settings^.OnClientConnected is nil at this time, because there is noway to set this param before create ws client,
ok , i know we can do it in the focContinuation frame, but ... just not so perfect.
Last edited by keinn (2024-01-25 09:40:24)
Offline
Why not just
- use THttpClientWebSockets.Create()
- then change the settings
- then call OpenBind()/ConnectUri(),
- then call WebSocketsUpgrade() ?
I have just added TCrtSocket.ConnectUri() which may be easier than OpenBind() to connect a client.
https://github.com/synopse/mORMot2/commit/b7e6e956
Offline