You can provide an anonymous method to the ForEachSession, like this:
procedure TServerContainer1.Test;
var
MyCurrentSession: TDSSession;
begin
MyCurrentSession := TDSSessionManager.Instance.GetThreadSession;
TDSSessionManager.Instance.ForEachSession(
procedure(const Session: TDSSession)
begin
// This procedure will be called for each session in the TDSSessionManager
if (Session.GetData('IDRETEA') <> '') and (MyCurrentSession.SessionName <> Session.SessionName) then
raise Exception.Create('Server busy. Try again later.');
end);
MyCurrentSession.PutData('IDRETEA', 'busy');
end;
Actually you just need to provide a method with this signature:
procedure(const Session: TDSSession)