Managing SuperSocket AppSessions Externally

Aug 28, 2013 at 11:30 AM
Edited Aug 28, 2013 at 11:50 AM

Is there a way I can freely manage the socket sessions created by an AppServer externally?

I'm fooling around with AppSessions because I want to be able to access the TrySend and Send method of a session wherever in a system (i.e. even if I'm not within the context of a ServerCommand).

While fiddling with ServerCommands (Commands that implement CommandBase), I saw that the AppServer instance found in them has a method that goes something like getListOfAppSessions from where I can access (and hopefully manage through memory) the sessions on my own.

Knowing that, I attempted to access the list of AppSessions through my AppServer right after the bootloader kicks in. So I made a class that will manages AppServers and register them immediately after the bootloader, and from that manager I though I could access the AppSessions.

Unfortunately though, I found out that the AppServer type returned by the bootloader is way different than the one I found in my implementation of a CommandBase. Seems like the ones in the bootloader contained only AppServer summaries, not the AppServer itself.

As a workaround, I made my own AppSession manager class that registers an AppSession during a particular ServerCommand.

While the concept of registering and accessing the session works, I am now stumped as of how do I remove an AppSession properly from my manager whenever the AppServer has closed it down after idling for too long (I use these attributes to close idle sessions: clearIdleSession="true" idleSessionTimeOut="300" clearIdleSessionInterval="120").

I can't think of a way to send a signal from an AppServer when it closes down an AppSession. Something that would enable me to go "Hey the AppServer said it's closing down this session, remove it from your session manager."

  1. Is there a more proper way to manage AppSessions than what I've already implemented?
  2. How can I access the AppSessions right after the bootloader loads? Such as I can already manipulate the AppSessions through memory with the use of an AppSession manager class in a different DLL?
Aug 29, 2013 at 8:50 AM
This kind container should be defined in your AppServer implementation and the hook the connection connected and closed event to maintain your sessions in your container.
Aug 29, 2013 at 9:14 AM
Edited Aug 29, 2013 at 9:15 AM
Hi thanks for the reply, I've found a work around in the AppServer that enables me to call my socketsession manager class.

I overridded the OnSessionClosed method on the AppServer.

I do something like this:
protected override void OnSessionClosed(MyAppSession session, CloseReason reason)
            // Call the base class' OnSessionClosed method.
            base.OnSessionClosed(session, reason);

            // Remove the session from the Manager
Is this good enough?
Aug 29, 2013 at 9:31 AM
It's correct!
Aug 29, 2013 at 9:56 AM
cool! thanks!