1 #include "SessionController.hpp"
2 #include "Exceptions.hpp"
5 SessionController::SessionController()
8 SessionController::~SessionController()
12 void SessionController::Tick( const std::list
<int>& activeFds
)
14 for( std::list
<SessionPtr
>::iterator it
= m_list
.begin(); it
!= m_list
.end(); ++it
)
16 std::list
<int> fds
= (*it
)->GetFds();
19 for( std::list
<int>::const_iterator af
= activeFds
.begin(); af
!= activeFds
.end(); ++af
)
21 for( std::list
<int>::const_iterator f
= fds
.begin(); f
!= fds
.end(); ++f
)
23 if( abs( *f
) == *af
)
38 while( !m_removeList
.empty() )
40 unsigned int size
= m_list
.size();
41 m_list
.remove( m_removeList
.front() );
43 if( m_list
.size() != size
- 1 )
45 g_log
->Print( "Removal of not registered session was requested" );
46 throw ServerCrashException
;
51 void SessionController::Add( const SessionPtr
& session
)
53 m_list
.push_back( session
);
56 void SessionController::Remove( const SessionPtr
& session
)
58 m_removeList
.push( session
);
61 std::list
<int> SessionController::GetFds() const
65 for( std::list
<SessionPtr
>::const_iterator it
= m_list
.begin(); it
!= m_list
.end(); ++it
)
67 std::list
<int> fds
= (*it
)->GetFds();
68 ret
.insert( ret
.end(), fds
.begin(), fds
.end() );