#1 2021-04-21 20:04:58

radexpol
Member
From: Poland, Krk
Registered: 2019-11-29
Posts: 116

Keep Alive

Does the TSQLHttpClientWebsockets supports keep alive? I mean I want to know if my RestHttpServer is alive. Now I've implemented the extra thread for that but maybe I can use any built-in mechanism. I'm also not sure if I can use the TSQLHttpClientWebsockets requests from thread.

type
  TPingThread = class(TThread)
  private
    Connector: TSQLHttpClientWebsockets;
    event: TEvent;
    procedure Ping;
  protected
    procedure Execute; override;
  public
    procedure Terminate;
    constructor Create(AConnector: TSQLHttpClientWebsockets);
    destructor Destroy; override;
  end;

implementation

procedure TPingThread.Execute;
begin
  inherited;
  while not Terminated do
  begin
    if event.WaitFor(10000) = wrTimeout then
      Ping
  end;
end;

procedure TPingThread.Ping;
begin
  if not Connector.ServerTimestampSynchronize then  -> is Connector thread safe ?
    PostMessage(Application.Handle, WM_QUIT, 0, 0);// Terminate;
end;

Offline

#2 2021-04-21 20:57:11

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: Keep Alive

TSQLHttpClientWebsockets has a ping/pong built-in mechanism as part of the WebSockets specification.

No need to call the server manually.

Offline

#3 2021-04-21 21:44:42

radexpol
Member
From: Poland, Krk
Registered: 2019-11-29
Posts: 116

Re: Keep Alive

How can I change ping time?

Offline

#4 2021-04-22 07:39:52

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: Keep Alive

Search in SynCrtSock documentation.

Offline

Board footer

Powered by FluxBB