TotalConnectionCount is increased before the first event is called and decreased after the last event was executed, which means that you should use "TotalConnectionCount-1" from the OnDisconnect/OnDisconnecting event.
Btw .. there's no need to cast Sender to TRtcConnection, since it already is TRtcConnection. You should only cast it to TRtcDataServer if you need more infromation.
Also, if your Server is MultiThreaded, you need to Sync() your events before accessing the GUI:
procedure TfrmMain.HttpServerConnect(Sender: TRtcConnection);
begin
if not Sender.inMainThread then
Sender.Sync(HttpServerConnect)
else
edtConnections.IntValue := Sender.TotalConnectionCount;
end;
procedure TfrmMain.HttpServerDisconnect(Sender: TRtcConnection);
begin
if not Sender.inMainThread then
Sender.Sync(HttpServerDisconnect)
else
edtConnections.IntValue := Sender.TotalConnectionCount-1;
end;
Best Regards,
Danijel Tkalcec