How to limit a process to one session?

I'm able to scan all call stacks, here is a working example:

MyClass myClass;
str callStack;
xSession session;
Counter i;
int classNamePos;
#AOT
;

myClass = MyClass::construct();

for (i = 1; i <= xSession::maxSessionId(); i++)
{
session = new xSession(i, true);

if (session && session.userId() && session.sessionId() != sessionId())
{
callStack = con2Str(xSession::xppCallStack());
classNamePos = strScan(callStack, #ClassesPath + '\\' + classstr(myClass), 1, strLen(callStack));

if (classNamePos > 0)
{
warning(strFmt("%1 is currently running this function.", (select userInfo where userInfo.Id == session.UserId()).Name));
return;
}
}
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.