Search code examples
androiddelphidatasnapdelphi-10.2-tokyo

List of devices connected to DataSnap Server


Does anyone know how to get IDs of devices connected to DataSnap Server? I made an application which uses DataSnap Server and I want to limit the connection and identify the connected devices.


Solution

  • This might help

    procedure TServerContainer1.DSServer1Connect(
      DSConnectEventObject: TDSConnectEventObject);
    var
      UserName: String;
      ClientInfo: TDBXClientInfo;
      logmsg: String;
      i: Integer;
    begin
      // Note: this event handler gets called directly AFTER authentication
      UserName := TDSSessionManager.GetThreadSession.GetData('UserName');
      ClientInfo := DSConnectEventObject.ChannelInfo.ClientInfo;
      logmsg := Format('User %s connected via %s from IP address %s',
        [UserName, ClientInfo.Protocol, ClientInfo.IpAddress]);
      // ... 
    end;