Help to Get the Sessions ID

Hi everyone,
I have 2 questions
First one:
I need to get all Sessions IDs to send msg to them using the message handler, there are any way to do that?
Second one:
if i try to get The current SessionId to pass the message directly with this code:

String SessionId = InternalSession.SESSION.get().getSession().getSessionId().toString();

I got this error:

java.lang.NullPointerException: null

I think I had misunderstood using InternalSession, should I import its package and use it directly or declare it in specific Scope
Thanks in advanced

perspective or vision?

perspective

And you are trying to do this in a model (more specific the gateway delegate)?

Or just trying to get it through a (system) function so you can use it in an external lib?

I made a (system) function for that once like this.

You'll also need to register these functions in the gateway and designer

You can probably get all the sessionInfo's from here
com/inductiveautomation/ignition/common/script/builtin/SystemUtilities.html#getSessionInfo()

1 Like

Thanks, Victor,
My fault that I didn't set Gatewaycontext,
Thank you again :heart:

1 Like

Whay is the proper way to set the gatewayContext?

You capture it in your module's setup hook and save it in a field. I tend to use a private static field and matching getter so the rest of the module can obtain it via that static method.

Proper indeed, thanks @pturmel.