/// <summary> /// This method must get timedout sessions and end them. /// </summary> private void OnSessionTimeoutTimer() { try{ // Close/Remove timed out sessions lock (m_pSessions){ ISocketServerSession[] sessions = new ISocketServerSession[m_pSessions.Count]; m_pSessions.Values.CopyTo(sessions, 0); // Loop sessions and and call OnSessionTimeout() for timed out sessions. for (int i = 0; i < sessions.Length; i++) { // If session throws exception, handle it here or next sessions timouts are not handled. try{ // Session timed out if (DateTime.Now > sessions[i].SessionLastDataTime.AddMilliseconds(this.SessionIdleTimeOut)) { sessions[i].OnSessionTimeout(); } } catch (Exception x) { OnSysError("OnTimer:", x); } } } } catch (Exception x) { OnSysError("WE MUST NEVER REACH HERE !!! OnTimer:", x); } }
/// <summary> /// This method must get timedout sessions and end them. /// </summary> private void OnSessionTimeoutTimer() { try{ // Close/Remove timed out sessions lock(m_pSessions){ ISocketServerSession[] sessions = new ISocketServerSession[m_pSessions.Count]; m_pSessions.Values.CopyTo(sessions,0); // Loop sessions and and call OnSessionTimeout() for timed out sessions. for(int i=0;i<sessions.Length;i++){ // If session throws exception, handle it here or next sessions timouts are not handled. try{ // Session timed out if(DateTime.Now > sessions[i].SessionLastDataTime.AddMilliseconds(this.SessionIdleTimeOut)){ sessions[i].OnSessionTimeout(); } } catch(Exception x){ OnSysError("OnTimer:",x); } } } } catch(Exception x){ OnSysError("WE MUST NEVER REACH HERE !!! OnTimer:",x); } }