cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Mashup: Execute Service when Session Started and Stopped

cjjaeckson
6-Contributor

Mashup: Execute Service when Session Started and Stopped

Hi community!

 

Is there somebody who knows if there is a possibility to execute a service, when a session has started or stopped? And is there a variable where I can see the number of currently opened Mashups/Sessions?

 

My problem is as followed:

I have a webcamscream running on an ems which can be started oder stopped by a service (stopStream, startStream) in TWX. My goal is that the webcam is just active when a user has the mashup opened.

I didn't found a solution on google...unfortunately. 

Hoping for help!

 

Chris

1 ACCEPTED SOLUTION

Accepted Solutions
nmutter
14-Alexandrite
(To:cjjaeckson)

Regarding Session started / ended: The "SecurityMonitor" has events you can subscribe to

nmutter_0-1669380748137.png

But this is specific to the whole platform - not to the mashup you'd like to have. I am also not sure, if a session timeout creates a Logout event (e.g. user was inactive for 30 minutes). So just as a FYI.

 

My quick idea/hack for your issue would be

- to create a thing with e.g. a datetime property.

- In the mashup you update the property in an interval. So every user having the mashup open will write to this property.

- You also create a scheduler, which runs e.g. every minute and checks for the property value. If the property value is older than x - you assume no one uses the mashup so you close the stream (if open). if it was written to previously you start it (if not already started).

View solution in original post

3 REPLIES 3
PaiChung
22-Sapphire I
(To:cjjaeckson)

Within the Server you can get 'active sessions' or 'users logged in'

That may or may not be enough for you to determine if you want to activate or deactivate something

As for a 'session start' you could use the 'FormLogin' and direct it to a mashup that uses a Mashup load.

There is no way to have an event to the server on session end, unless users click on some logout button.

since session end means you can't contact the server anymore from the client without authentication.

nmutter
14-Alexandrite
(To:cjjaeckson)

Regarding Session started / ended: The "SecurityMonitor" has events you can subscribe to

nmutter_0-1669380748137.png

But this is specific to the whole platform - not to the mashup you'd like to have. I am also not sure, if a session timeout creates a Logout event (e.g. user was inactive for 30 minutes). So just as a FYI.

 

My quick idea/hack for your issue would be

- to create a thing with e.g. a datetime property.

- In the mashup you update the property in an interval. So every user having the mashup open will write to this property.

- You also create a scheduler, which runs e.g. every minute and checks for the property value. If the property value is older than x - you assume no one uses the mashup so you close the stream (if open). if it was written to previously you start it (if not already started).

cjjaeckson
6-Contributor
(To:nmutter)

Thanks a lot! I will try that. It feels a little bit bungled, but it should work.

Top Tags