TsgcWebSocketServer  | Client Connections

To access the active client connections, you can use the Connections property to iterate through the list and access the client connection class. The Connections property accesses a threaded list, so first lock the list and when you are finished, unlock the list.

 


procedure DoClientIPAddresses;
var
  i: Integer;
  oList: TList;
  oConnection: TsgcWSConnectionServer;
begin
  oList := TsgcWebSocketHTTPServer1.LockList;
  Try
    for i := 0 to oList.Count - 1 do
    begin
      oConnection := TsgcWSConnectionServer(TIdContext(oList[i]).Data);
      ShowMessage(oConnection.IP + ':' + IntToStr(oConnection.Port));
    end;
  Finally
    TsgcWebSocketHTTPServer1.UnLockList;
  End;
end;