AmSessionContainer.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00028 #ifndef AmSessionContainer_h
00029 #define AmSessionContainer_h
00030
00031 #include "AmThread.h"
00032 #include "AmSession.h"
00033
00034 #include <string>
00035 #include <queue>
00036 #include <map>
00037
00038 using std::string;
00039
00048 class AmSessionContainer : public AmThread
00049 {
00050 static AmSessionContainer* _SessionContainer;
00051
00052
00053 typedef std::map<string,AmSession*> SessionMap;
00054 typedef SessionMap::iterator SessionMapIter;
00055
00056 typedef std::map<string,string> Dictionnary;
00057 typedef Dictionnary::iterator DictIter;
00058
00059 typedef std::queue<AmSession*> SessionQueue;
00060
00065 SessionMap a_sessions;
00066
00072 Dictionnary as_id_lookup;
00073
00075 AmMutex as_mut;
00076
00077
00079 SessionQueue d_sessions;
00081 AmMutex ds_mut;
00082
00084 AmCondition<bool> _run_cond;
00085
00087 AmSessionContainer();
00088
00096 AmSession* getSession(const string& callid, const string& remote_tag);
00097
00104 AmSession* getSession(const string& local_tag);
00105
00110 bool addSession_unsafe(const string& callid,
00111 const string& remote_tag,
00112 const string& local_tag,
00113 AmSession* session);
00114
00119 bool addSession_unsafe(const string& local_tag,
00120 AmSession* session);
00121
00125 void stopAndQueue(AmSession* s);
00126
00128 void run();
00130 void on_stop();
00131
00132 public:
00133 static AmSessionContainer* instance();
00134
00140 AmSession* createSession(AmSipRequest& req,
00141 AmArg* session_params = NULL);
00142
00147 bool addSession(const string& callid,
00148 const string& remote_tag,
00149 const string& local_tag,
00150 AmSession* session);
00151
00156 bool addSession(const string& local_tag,
00157 AmSession* session);
00158
00163 void startSessionUAS(AmSipRequest& req);
00164
00169 AmSession* startSessionUAC(AmSipRequest& req,
00170 AmArg* session_params = NULL);
00171
00175 void destroySession(AmSession* s);
00176 void destroySession(const string& local_tag);
00177
00181 int getSize();
00182
00187 bool postEvent(const string& callid, const string& remote_tag,
00188 AmEvent* event);
00189
00198 bool postEvent(const string& local_tag, AmEvent* event);
00199 };
00200
00201 #endif
Generated on Fri May 16 12:02:05 2008 for SEMS by
1.5.1