As the server load increase we may need to kow number os simultanious sessiona and whether there is any session remain live due to wrong client implementations. This will help us to keep track of sessions
As far as I know there is no direct way to determin number of active sessions in WCF server implementation. To over come this we will create a bass class from all our service classes to derive.
Base class will named SessionBase and it contains a constructor and destructor. Which is most important thing in the implementation. In addition to that it will contain a pair of static public events
SessionBase
{
public SessionBase()
{
}
~SessionBase()
{
}
}
SessionEvent
{
EventType ( Created, Destructed)
StartTime
ServiceName
SessionID
}
Class Structure
Contructor
- Collect creation time
- Create SessionID (Use Time Tick + Rand Number)( Or by incrementing a static member . Use interlocked increement)
- Fill Event arguments with ServiceName (use this.GetType()), sessionID etc
- Fire the event
- Fill Event arguments with ServiceName (use this.GetType()), sessionID etc
- Fire the event