#include <rtp.h>
Construction | |
RTP_SessionManager () | |
RTP_SessionManager (const RTP_SessionManager &sm) | |
RTP_SessionManager & | operator= (const RTP_SessionManager &sm) |
Public Member Functions | |
Operations | |
RTP_Session * | UseSession (unsigned sessionID) |
void | AddSession (RTP_Session *session) |
void | ReleaseSession (unsigned sessionID, BOOL clearAll=FALSE) |
RTP_Session * | GetSession (unsigned sessionID) const |
RTP_Session * | First () |
RTP_Session * | Next () |
void | Exit () |
Protected Member Functions | |
PDICTIONARY (SessionDict, POrdinalKey, RTP_Session) | |
Protected Attributes | |
SessionDict | sessions |
PMutex | mutex |
PINDEX | enumerationIndex |
RTP_SessionManager::RTP_SessionManager | ( | ) |
Construct new session manager database.
RTP_SessionManager::RTP_SessionManager | ( | const RTP_SessionManager & | sm | ) |
RTP_SessionManager& RTP_SessionManager::operator= | ( | const RTP_SessionManager & | sm | ) |
RTP_Session* RTP_SessionManager::UseSession | ( | unsigned | sessionID | ) |
Use an RTP session for the specified ID.
If this function returns a non-null value, then the ReleaseSession() function MUST be called or the session is never deleted for the lifetime of the session manager.
If there is no session of the specified ID, then you MUST call the AddSession() function with a new RTP_Session. The mutex flag is left locked in this case. The AddSession() expects the mutex to be locked and unlocks it automatically.
sessionID | Session ID to use. |
void RTP_SessionManager::AddSession | ( | RTP_Session * | session | ) |
Add an RTP session for the specified ID.
This function MUST be called only after the UseSession() function has returned NULL. The mutex flag is left locked in that case. This function expects the mutex to be locked and unlocks it automatically.
session | Session to add. |
void RTP_SessionManager::ReleaseSession | ( | unsigned | sessionID, | |
BOOL | clearAll = FALSE | |||
) |
Release the session. If the session ID is not being used any more any clients via the UseSession() function, then the session is deleted.
sessionID | Session ID to release. |
clearAll | Clear all sessions with that ID |
RTP_Session* RTP_SessionManager::GetSession | ( | unsigned | sessionID | ) | const |
Get a session for the specified ID. Unlike UseSession, this does not increment the usage count on the session so may be used to just gain a pointer to an RTP session.
sessionID | Session ID to get. |
RTP_Session* RTP_SessionManager::First | ( | ) |
Begin an enumeration of the RTP sessions. This function acquires the mutex for the sessions database and returns the first element in it.
eg: RTP_Session * session; for (session = rtpSessions.First(); session != NULL; session = rtpSessions.Next()) { if (session->Something()) { rtpSessions.Exit(); break; } }
Note that the Exit() function must be called if the enumeration is stopped prior to Next() returning NULL.
RTP_Session* RTP_SessionManager::Next | ( | ) |
void RTP_SessionManager::Exit | ( | ) |
RTP_SessionManager::PDICTIONARY | ( | SessionDict | , | |
POrdinalKey | , | |||
RTP_Session | ||||
) | [protected] |
SessionDict RTP_SessionManager::sessions [protected] |
PMutex RTP_SessionManager::mutex [protected] |
PINDEX RTP_SessionManager::enumerationIndex [protected] |