TsgcWebSocketServer | Client Connections

활성 클라이언트 연결에 액세스하려면 Connections 속성을 사용하여 목록을 반복하고 클라이언트 연결 클래스에 액세스할 수 있습니다. Connections 속성은 스레드된 목록에 액세스하므로, 먼저 목록을 잠그고 완료되면 목록을 잠금 해제하십시오.

 


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;