Add more than 1 user on a session

Hi ,

I have a situation where 2 operators work on a station. While only one can login, there was no way for us to capture the other person's name. I created a button for authentication challenge and in return it would add 2nd operator,s name to session custom property and a flex repeater at the top would appear with his name. And by clicking on his name it will remove him from session custom propety as well. This I was able to capture more than 1 operators working at a station.

The only issue is, if the same 2nd operator logs in to other station. It allows him to aquire a session. However what i need to implement is it logs him out from their previous logged station not affecting the first operator who logged in initially.

I hope this explains the situation I am trying to tackle and happy to take your suggestions.

Thank you.

You have to create a dataset tag (or something) that stores the active sessions and their operators. That way all sessions can lookup the operators of the other sessions

Or, perhaps, broadcast every user auth result, both primary user and secondary user, to all other sessions. So the other sessions can kick them out.

Can you please explain in more detail of what do you mean by broadcast?

Use system.util.sendMessage() with scope=S (not system.perspective.sendMessage()), which targets session message handlers (defined in the session, not in any component).

from pageStartup event? or sessionStartup?

I get this .

Error running session.handleMessage(session, payload): Traceback (most recent call last): File "function:handleMessage", line 10, in handleMessage at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.lambda$operateOnPage$0(AbstractScriptingFunctions.java:64) at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnSession(AbstractScriptingFunctions.java:120) at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnPage(AbstractScriptingFunctions.java:47) at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.authenticationChallenge(PerspectiveScriptingFunctions.java:418) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: No perspective page attached to this thread.

What is your message handler code?

logger = system.util.getLogger('Operator Check - Page Startup')
current_username = payload['current_username']
Full_name = payload['Full_name']
session_id = payload['session_id']
Support_Users = session.custom.Support_Users

if session.props.id != session_id and session.props.auth.user.userName == current_username:
	system.perspective.logout(sessionID=session.props.id, message = Full_name + " Your account has been logged out due to log in at other station. Please contact supervisor for concerns.")
	logger.info("User automatic logout : %s , session: %d" % (current_username, session.props.id))

elif Full_name in Support_Users:
	Support_Users.remove(Full_name)
	logger.info("Support_User Kicked out : %s , session: %d" % (current_username, session.props.id))