TsgcWebSocketServer  | Client Connections

To access to the active client connections, you can use the Connections property to iterate through the list and access to the client connection class. The Connections properties access to a threaded list, so first lock the list and when you finish, 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;