Re: Session count
Re: Session count
- Subject: Re: Session count
- From: Thomas LATTER <email@hidden>
- Date: Mon, 12 Sep 2016 19:12:08 +0200
Hi Calvin,
My app was already fetching the application().activeSessionsCount() from the server every 30 seconds.
So now in the same DirectAction I also update a new small table in my database with a row for each of my instances and two columns(Instance ID, active count). I can now fetch this data and display the active counts of the other instances of my app. I had to add a little extra so that when an instance's last session terminated the count in the database would go down to zero, to do this I overrid the terminate() function in Session.java to something like this:
public void terminate(){
// If this is the last session on the instance we update the DB session count to 0 before terminating it
if(this.application().activeSessionsCount() == 1){
EOEditingContext editingContext = this.defaultEditingContext();
String instanceId = String.valueOf(this.context().request().applicationNumber());
WebInstance instance = WebInstance.fetchRequiredWebInstance(editingContext, ERXQ.equals(WebInstance.ID_KEY, Integer.valueOf(instanceId)));
instance.setActiveCount(0);
editingContext.saveChanges();
}
}
super.terminate();
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden