Browse code

b/f: core: init monitoring interface used by core after loading modules

Stefan Sayer authored on 21/12/2013 15:15:10
Showing 1 changed files
... ...
@@ -202,6 +202,8 @@ class AmSessionContainer : public AmThread
202 202
    */
203 203
   unsigned int getMaxCPS();
204 204
 
205
+  void initMonitoring();
206
+
205 207
   _MONITORING_DEFINE_INTERFACE;
206 208
 
207 209
 };
Browse code

core: CPS limiter Calls-per-sec limiting capability, similar to the maximum number of calls limiter. There is a "soft limit" that is intended to use by the applications: if the app uses async processing and detects that the incoming workload is too much for the currenti capacity (which can depend on for example the remote DB engine's load), it can slewi it back to some percent of the current CPS; then when the circumstances are restored it can switch the CPS limit back to the configuration (or XMLRPC/stats interface) mandated value.

Szókovács Róbert authored on 07/11/2013 14:59:47
Showing 1 changed files
... ...
@@ -82,6 +82,22 @@ class AmSessionContainer : public AmThread
82 82
 
83 83
   bool clean_sessions();
84 84
 
85
+  typedef std::queue<struct timeval> TimevalQueue;
86
+
87
+  /** Container for cps timevals*/
88
+  TimevalQueue cps_queue;
89
+  /** Maximum cps since the lasd getMaxCPS()*/
90
+  unsigned int max_cps;
91
+  /** Mutex to protect the cps container */
92
+  AmMutex      cps_mut;
93
+
94
+  enum { CPS_SAMPLERATE = 5 };
95
+
96
+  unsigned int CPSLimit;
97
+  unsigned int CPSHardLimit;
98
+
99
+  bool check_and_add_cps();
100
+
85 101
  public:
86 102
   static AmSessionContainer* instance();
87 103
 
... ...
@@ -165,6 +181,27 @@ class AmSessionContainer : public AmThread
165 181
   /** enable unclean shutdown (will not broadcastShutdown event) */
166 182
   void enableUncleanShutdown();
167 183
 
184
+  /** Set the maximum number of calls per second to be accepted */
185
+  void setCPSLimit(unsigned int limit);
186
+
187
+  /** Set the maximum number of calls per second to be accepted as a percent 
188
+   * of the current CPS. Intented to be used by the components. 0 means turning off
189
+   * the soft limit.
190
+   */
191
+  void setCPSSoftLimit(unsigned int percent);
192
+
193
+  /** Return the maximum number of calls per second to be accepted */
194
+  pair<unsigned int, unsigned int> getCPSLimit();
195
+
196
+  /**
197
+   * Gets the timeaverage of calls per second in the last CPS_SAMPLERATE sec window
198
+   */
199
+  unsigned int getAvgCPS();
200
+  /**
201
+   * Gets the maximum of calls per second since last query
202
+   */
203
+  unsigned int getMaxCPS();
204
+
168 205
   _MONITORING_DEFINE_INTERFACE;
169 206
 
170 207
 };
Browse code

propagate app_name to everywhere it is needed.

Raphael Coeffic authored on 10/05/2011 14:36:36
Showing 1 changed files
... ...
@@ -98,8 +98,8 @@ class AmSessionContainer : public AmThread
98 98
    * @param req local request
99 99
    * @return a new session or NULL on error.
100 100
    */
101
-  AmSession* createSession(AmSipRequest& req, 
102
-			   const string& app_name = "",
101
+  AmSession* createSession(const AmSipRequest& req, 
102
+			   string& app_name,
103 103
 			   AmArg* session_params = NULL);
104 104
 
105 105
   /**
... ...
@@ -129,8 +129,8 @@ class AmSessionContainer : public AmThread
129 129
    * Constructs a new session and adds it to the active session container. 
130 130
    * @param req client's request
131 131
    */
132
-  string startSessionUAC(AmSipRequest& req, 
133
-			     const string& app_name,
132
+  string startSessionUAC(const AmSipRequest& req, 
133
+			 string& app_name,
134 134
 			 AmArg* session_params = NULL);
135 135
 
136 136
   /**
Browse code

Merge branch 'master' into offer_answer

Raphael Coeffic authored on 05/04/2011 12:09:31
Showing 0 changed files
Browse code

added support for forked INVITEs

If an INVITE has been forked and more than one branch is aimed at SEMS,
then the branch parameter of the top-via is necessary to distinguish the
different sessions.

By default, SEMS will now accept forked INVITEs.
This behavior can be switched off by setting "accept_forked_dialogs" to "no" (default=yes).

Raphael Coeffic authored on 12/10/2010 13:51:16
Showing 1 changed files
... ...
@@ -108,6 +108,7 @@ class AmSessionContainer : public AmThread
108 108
   AddSessionStatus addSession(const string& callid,
109 109
 			      const string& remote_tag,
110 110
 			      const string& local_tag,
111
+			      const string& via_branch,
111 112
 			      AmSession* session);
112 113
 
113 114
   /**
... ...
@@ -139,7 +140,9 @@ class AmSessionContainer : public AmThread
139 140
    * post an event into the event queue of the identified dialog.
140 141
    * @return false if session doesn't exist 
141 142
    */
142
-  bool postEvent(const string& callid, const string& remote_tag,
143
+  bool postEvent(const string& callid, 
144
+		 const string& remote_tag,
145
+		 const string& via_branch,
143 146
 		 AmEvent* event);
144 147
 
145 148
   /**
Browse code

b/f: several minor bugs in session creation.

- the session pointer should not be touched after the session has been started (could be immediately destroyed).
- return 481 on CANCEL if the transaction cannot be found.
- reply properly with 482 if the UAS dialog already exists.

Raphael Coeffic authored on 24/03/2011 19:11:24
Showing 1 changed files
... ...
@@ -87,6 +87,12 @@ class AmSessionContainer : public AmThread
87 87
 
88 88
   static void dispose();
89 89
 
90
+  enum AddSessionStatus {
91
+    ShutDown,
92
+    Inserted,
93
+    AlreadyExist
94
+  };
95
+
90 96
   /**
91 97
    * Creates a new session.
92 98
    * @param req local request
... ...
@@ -99,17 +105,17 @@ class AmSessionContainer : public AmThread
99 105
    * Adds a session to the container (UAS only).
100 106
    * @return true if the session is new within the container.
101 107
    */
102
-  bool addSession(const string& callid,
103
-		  const string& remote_tag,
104
-		  const string& local_tag,
105
-		  AmSession* session);
108
+  AddSessionStatus addSession(const string& callid,
109
+			      const string& remote_tag,
110
+			      const string& local_tag,
111
+			      AmSession* session);
106 112
 
107 113
   /**
108 114
    * Adds a session to the container.
109 115
    * @return true if the session is new within the container.
110 116
    */
111
-  bool addSession(const string& local_tag,
112
- 		  AmSession* session);
117
+  AddSessionStatus addSession(const string& local_tag,
118
+			      AmSession* session);
113 119
 
114 120
   /** 
115 121
    * Constructs a new session and adds it to the active session container. 
... ...
@@ -121,8 +127,8 @@ class AmSessionContainer : public AmThread
121 127
    * Constructs a new session and adds it to the active session container. 
122 128
    * @param req client's request
123 129
    */
124
-  AmSession* startSessionUAC(AmSipRequest& req, 
125
-			     AmArg* session_params = NULL);
130
+  string startSessionUAC(AmSipRequest& req, 
131
+			 AmArg* session_params = NULL);
126 132
 
127 133
   /**
128 134
    * Detroys a session.
Browse code

Merge branch 'master' into offer_answer

Raphael Coeffic authored on 18/02/2011 11:36:25
Showing 1 changed files
... ...
@@ -67,6 +67,9 @@ class AmSessionContainer : public AmThread
67 67
   /** We are a Singleton ! Avoid people to have their own instance. */
68 68
   AmSessionContainer();
69 69
 
70
+
71
+  bool enable_unclean_shutdown;
72
+
70 73
   /**
71 74
    * Tries to stop the session and queue it destruction.
72 75
    */
... ...
@@ -150,6 +153,9 @@ class AmSessionContainer : public AmThread
150 153
    */
151 154
   void  broadcastShutdown();
152 155
 
156
+  /** enable unclean shutdown (will not broadcastShutdown event) */
157
+  void enableUncleanShutdown();
158
+
153 159
   _MONITORING_DEFINE_INTERFACE;
154 160
 
155 161
 };
Browse code

SIGTERM stops server without sending BYE

SIGHUP - broadcast shutdown, usually sends BYE and stops all calls. The server does not terminate.
SIGINT - broadcast shutdown (usually sends BYE and stops all calls), and stop.
SIGTERM - stop the server, without broadcasting shutdown (no BYEs sent).

Stefan Sayer authored on 02/02/2011 16:35:54
Showing 1 changed files
... ...
@@ -67,6 +67,9 @@ class AmSessionContainer : public AmThread
67 67
   /** We are a Singleton ! Avoid people to have their own instance. */
68 68
   AmSessionContainer();
69 69
 
70
+
71
+  bool enable_unclean_shutdown;
72
+
70 73
   /**
71 74
    * Tries to stop the session and queue it destruction.
72 75
    */
... ...
@@ -148,6 +151,9 @@ class AmSessionContainer : public AmThread
148 151
    */
149 152
   void  broadcastShutdown();
150 153
 
154
+  /** enable unclean shutdown (will not broadcastShutdown event) */
155
+  void enableUncleanShutdown();
156
+
151 157
   _MONITORING_DEFINE_INTERFACE;
152 158
 
153 159
 };
Browse code

Merge branch 'master' into offer_answer

Raphael Coeffic authored on 13/10/2010 14:04:23
Showing 0 changed files
Browse code

added OpenSSL linking exception to license

Stefan Sayer authored on 23/09/2010 14:41:49
Showing 1 changed files
... ...
@@ -1,21 +1,21 @@
1 1
 /*
2
- * $Id$
3
- *
4 2
  * Copyright (C) 2002-2003 Fhg Fokus
5 3
  *
6
- * This file is part of sems, a free SIP media server.
4
+ * This file is part of SEMS, a free SIP media server.
7 5
  *
8
- * sems is free software; you can redistribute it and/or modify
6
+ * SEMS is free software; you can redistribute it and/or modify
9 7
  * it under the terms of the GNU General Public License as published by
10 8
  * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version
9
+ * (at your option) any later version. This program is released under
10
+ * the GPL with the additional exemption that compiling, linking,
11
+ * and/or using OpenSSL is allowed.
12 12
  *
13
- * For a license to use the ser software under conditions
13
+ * For a license to use the SEMS software under conditions
14 14
  * other than those described here, or to purchase support for this
15 15
  * software, please contact iptel.org by e-mail at the following addresses:
16 16
  *    info@iptel.org
17 17
  *
18
- * sems is distributed in the hope that it will be useful,
18
+ * SEMS is distributed in the hope that it will be useful,
19 19
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 20
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 21
  * GNU General Public License for more details.
Browse code

handle SIGHUP: stop sessions (send BYE), dont quit

Stefan Sayer authored on 22/09/2010 13:49:04
Showing 1 changed files
... ...
@@ -143,6 +143,11 @@ class AmSessionContainer : public AmThread
143 143
    */
144 144
   bool postEvent(const string& local_tag, AmEvent* event);
145 145
 
146
+  /** 
147
+   * broadcasts a server shutdown system event to all sessions
148
+   */
149
+  void  broadcastShutdown();
150
+
146 151
   _MONITORING_DEFINE_INTERFACE;
147 152
 
148 153
 };
Browse code

re-organized AmSipMsg

Raphael Coeffic authored on 28/06/2010 11:28:40
Showing 1 changed files
... ...
@@ -90,6 +90,7 @@ class AmSessionContainer : public AmThread
90 90
    * @return a new session or NULL on error.
91 91
    */
92 92
   AmSession* createSession(AmSipRequest& req, 
93
+			   const string& app_name = "",
93 94
 			   AmArg* session_params = NULL);
94 95
 
95 96
   /**
... ...
@@ -118,7 +119,8 @@ class AmSessionContainer : public AmThread
118 119
    * Constructs a new session and adds it to the active session container. 
119 120
    * @param req client's request
120 121
    */
121
-  AmSession* startSessionUAC(AmSipRequest& req, 
122
+  AmSession* startSessionUAC(AmSipRequest& req,
123
+			     const string& app_name,
122 124
 			     AmArg* session_params = NULL);
123 125
 
124 126
   /**
Browse code

initial support for better call/server monitoring

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1259 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Stefan Sayer authored on 10/02/2009 12:17:15
Showing 1 changed files
... ...
@@ -31,6 +31,8 @@
31 31
 #include "AmThread.h"
32 32
 #include "AmSession.h"
33 33
 
34
+#include "ampi/MonitoringAPI.h"
35
+
34 36
 #include <string>
35 37
 #include <queue>
36 38
 #include <map>
... ...
@@ -140,6 +142,9 @@ class AmSessionContainer : public AmThread
140 142
    * @return false if session doesn't exist 
141 143
    */
142 144
   bool postEvent(const string& local_tag, AmEvent* event);
145
+
146
+  _MONITORING_DEFINE_INTERFACE;
147
+
143 148
 };
144 149
 
145 150
 #endif
Browse code

first steps on proper shutdown: - active sessions and other event receivers get a SystemEvent::ServerShutdown, default behaviour of AmSession is setStopped() - session container waits for all sessions to be ended - signaling server, rtp receiver, media processor, event dispatcher are stopped and deleted

based on a patch by Rui Jin Zheng rjzheng at boronetworks dot com



git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1087 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Stefan Sayer authored on 23/09/2008 19:03:46
Showing 1 changed files
... ...
@@ -47,7 +47,7 @@ using std::string;
47 47
  */
48 48
 class AmSessionContainer : public AmThread
49 49
 {
50
-  static AmSessionContainer* _SessionContainer;
50
+  static AmSessionContainer* _instance;
51 51
 
52 52
   typedef std::queue<AmSession*>      SessionQueue;
53 53
 
... ...
@@ -56,6 +56,9 @@ class AmSessionContainer : public AmThread
56 56
   /** Mutex to protect the dead session container */
57 57
   AmMutex      ds_mut;
58 58
 
59
+  /** is container closed for new sessions? */
60
+  AmCondition<bool> _container_closed;
61
+
59 62
   /** the daemon only runs if this is true */
60 63
   AmCondition<bool> _run_cond;
61 64
 
... ...
@@ -72,9 +75,13 @@ class AmSessionContainer : public AmThread
72 75
   /** @see AmThread::on_stop() */
73 76
   void on_stop();
74 77
 
78
+  bool clean_sessions();
79
+
75 80
  public:
76 81
   static AmSessionContainer* instance();
77 82
 
83
+  static void dispose();
84
+
78 85
   /**
79 86
    * Creates a new session.
80 87
    * @param req local request
Browse code

- 2nd part of the last commit.

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1029 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Raphael Coeffic authored on 23/06/2008 16:35:10
Showing 1 changed files
... ...
@@ -116,7 +116,6 @@ class AmSessionContainer : public AmThread
116 116
    * Detroys a session.
117 117
    */
118 118
   void destroySession(AmSession* s);
119
-  void destroySession(const string& local_tag);
120 119
 
121 120
   /**
122 121
    * post an event into the event queue of the identified dialog.
Browse code

- moved the "dialog-lookup-container" away from the session container into AmEventDispatcher. - removed AmSIPEventHandler (its functionalities are now in AmEventDispatcher). - added possibility for each plug-in to receive out-of-dialog messages (any kind). - added possibility to handle dialogs without creating a session (=AmSession).

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1006 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Raphael Coeffic authored on 04/06/2008 10:56:01
Showing 1 changed files
... ...
@@ -49,32 +49,8 @@ class AmSessionContainer : public AmThread
49 49
 {
50 50
   static AmSessionContainer* _SessionContainer;
51 51
 
52
-  // some typedefs ...
53
-  typedef std::map<string,AmSession*> SessionMap;
54
-  typedef SessionMap::iterator SessionMapIter;
55
-
56
-  typedef std::map<string,string>     Dictionnary;
57
-  typedef Dictionnary::iterator  DictIter;
58
-
59 52
   typedef std::queue<AmSession*>      SessionQueue;
60 53
 
61
-  /** 
62
-   * Container for active sessions 
63
-   * local tag -> session
64
-   */
65
-  SessionMap a_sessions;
66
-
67
-  /** 
68
-   * Call ID + remote tag -> local tag 
69
-   *  (needed for CANCELs and some provisionnal answers)
70
-   *  (UAS sessions only)
71
-   */
72
-  Dictionnary as_id_lookup;
73
-
74
-  /** Mutex to protect the active session container */
75
-  AmMutex    as_mut;
76
-
77
-
78 54
   /** Container for dead sessions */
79 55
   SessionQueue d_sessions;
80 56
   /** Mutex to protect the dead session container */
... ...
@@ -86,39 +62,6 @@ class AmSessionContainer : public AmThread
86 62
   /** We are a Singleton ! Avoid people to have their own instance. */
87 63
   AmSessionContainer();
88 64
 
89
-  /**
90
-   * Search the container for a session coresponding 
91
-   * to callid and remote_tag. (UAS only).
92
-   *
93
-   * @return the session related to callid & remote_tag
94
-   *         or NULL if none has been found.
95
-   */
96
-  AmSession* getSession(const string& callid, const string& remote_tag);
97
-
98
-  /**
99
-   * Search the container for a session coresponding to local_tag.
100
-   *
101
-   * @return the session related to local_tag 
102
-   *         or NULL if none has been found.
103
-   */
104
-  AmSession* getSession(const string& local_tag);
105
-
106
-  /**
107
-   * Adds a session to the container. (UAS only)
108
-   * @return true if the session is new within the container.
109
-   */
110
-  bool addSession_unsafe(const string& callid, 
111
-			 const string& remote_tag,
112
-			 const string& local_tag,
113
-			 AmSession* session);
114
-
115
-  /**
116
-   * Adds a session to the container.
117
-   * @return true if the session is new within the container.
118
-   */
119
-  bool addSession_unsafe(const string& local_tag,
120
-			 AmSession* session);
121
-
122 65
   /**
123 66
    * Tries to stop the session and queue it destruction.
124 67
    */
... ...
@@ -154,7 +97,7 @@ class AmSessionContainer : public AmThread
154 97
    * @return true if the session is new within the container.
155 98
    */
156 99
   bool addSession(const string& local_tag,
157
-		  AmSession* session);
100
+ 		  AmSession* session);
158 101
 
159 102
   /** 
160 103
    * Constructs a new session and adds it to the active session container. 
... ...
@@ -175,11 +118,6 @@ class AmSessionContainer : public AmThread
175 118
   void destroySession(AmSession* s);
176 119
   void destroySession(const string& local_tag);
177 120
 
178
-  /**
179
-   * Query the number of active sessions
180
-   */
181
-  int getSize();
182
-
183 121
   /**
184 122
    * post an event into the event queue of the identified dialog.
185 123
    * @return false if session doesn't exist 
Browse code

fixes for SEMS on Solaris contributed by Richard Newman rnewman at twinql dot com

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@633 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Stefan Sayer authored on 28/01/2008 18:17:36
Showing 1 changed files
... ...
@@ -32,14 +32,10 @@
32 32
 #include "AmSession.h"
33 33
 
34 34
 #include <string>
35
-#include <vector>
36 35
 #include <queue>
37 36
 #include <map>
38 37
 
39 38
 using std::string;
40
-using std::vector;
41
-using std::queue;
42
-using std::map;
43 39
 
44 40
 /**
45 41
  * \brief Centralized session container.
... ...
@@ -54,13 +50,13 @@ class AmSessionContainer : public AmThread
54 50
   static AmSessionContainer* _SessionContainer;
55 51
 
56 52
   // some typedefs ...
57
-  typedef map<string,AmSession*> SessionMap;
53
+  typedef std::map<string,AmSession*> SessionMap;
58 54
   typedef SessionMap::iterator SessionMapIter;
59 55
 
60
-  typedef map<string,string>     Dictionnary;
56
+  typedef std::map<string,string>     Dictionnary;
61 57
   typedef Dictionnary::iterator  DictIter;
62 58
 
63
-  typedef queue<AmSession*>      SessionQueue;
59
+  typedef std::queue<AmSession*>      SessionQueue;
64 60
 
65 61
   /** 
66 62
    * Container for active sessions 
Browse code

train ride doxygen documentation

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@457 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Stefan Sayer authored on 24/09/2007 17:37:04
Showing 1 changed files
... ...
@@ -24,7 +24,7 @@
24 24
  * along with this program; if not, write to the Free Software 
25 25
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 26
  */
27
-
27
+/** @file AmSessionContainer.h */
28 28
 #ifndef AmSessionContainer_h
29 29
 #define AmSessionContainer_h
30 30
 
Browse code

allows to give dialout sessions a variant parameter with the call to AmUAC::dialout. Plugin interface stays backward compatible by overloading the AmSessionFactory::onInvite - applications that want to use this feature need to implement the onInvite function with second parameter.

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@336 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Stefan Sayer authored on 28/05/2007 21:33:49
Showing 1 changed files
... ...
@@ -141,7 +141,8 @@ class AmSessionContainer : public AmThread
141 141
    * @param req local request
142 142
    * @return a new session or NULL on error.
143 143
    */
144
-  AmSession* createSession(AmSipRequest& req);
144
+  AmSession* createSession(AmSipRequest& req, 
145
+			   AmArg* session_params = NULL);
145 146
 
146 147
   /**
147 148
    * Adds a session to the container (UAS only).
... ...
@@ -169,7 +170,8 @@ class AmSessionContainer : public AmThread
169 170
    * Constructs a new session and adds it to the active session container. 
170 171
    * @param req client's request
171 172
    */
172
-  AmSession* startSessionUAC(AmSipRequest& req);
173
+  AmSession* startSessionUAC(AmSipRequest& req, 
174
+			     AmArg* session_params = NULL);
173 175
 
174 176
   /**
175 177
    * Detroys a session.
Browse code

unifies indentation level in all source files to 2 (-i2)

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@261 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Stefan Sayer authored on 07/03/2007 20:34:39
Showing 1 changed files
... ...
@@ -1,3 +1,30 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ * Copyright (C) 2002-2003 Fhg Fokus
5
+ *
6
+ * This file is part of sems, a free SIP media server.
7
+ *
8
+ * sems is free software; you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation; either version 2 of the License, or
11
+ * (at your option) any later version
12
+ *
13
+ * For a license to use the ser software under conditions
14
+ * other than those described here, or to purchase support for this
15
+ * software, please contact iptel.org by e-mail at the following addresses:
16
+ *    info@iptel.org
17
+ *
18
+ * sems is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License 
24
+ * along with this program; if not, write to the Free Software 
25
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
+ */
27
+
1 28
 #ifndef AmSessionContainer_h
2 29
 #define AmSessionContainer_h
3 30
 
... ...
@@ -24,153 +51,153 @@ using std::map;
24 51
  */
25 52
 class AmSessionContainer : public AmThread
26 53
 {
27
-    static AmSessionContainer* _SessionContainer;
28
-
29
-    // some typedefs ...
30
-    typedef map<string,AmSession*> SessionMap;
31
-    typedef SessionMap::iterator SessionMapIter;
32
-
33
-    typedef map<string,string>     Dictionnary;
34
-    typedef Dictionnary::iterator  DictIter;
35
-
36
-    typedef queue<AmSession*>      SessionQueue;
37
-
38
-    /** 
39
-     * Container for active sessions 
40
-     * local tag -> session
41
-     */
42
-    SessionMap a_sessions;
43
-
44
-    /** 
45
-     * Call ID + remote tag -> local tag 
46
-     *  (needed for CANCELs and some provisionnal answers)
47
-     *  (UAS sessions only)
48
-     */
49
-    Dictionnary as_id_lookup;
50
-
51
-    /** Mutex to protect the active session container */
52
-    AmMutex    as_mut;
53
-
54
-
55
-    /** Container for dead sessions */
56
-    SessionQueue d_sessions;
57
-    /** Mutex to protect the dead session container */
58
-    AmMutex      ds_mut;
59
-
60
-    /** the daemon only runs if this is true */
61
-    AmCondition<bool> _run_cond;
62
-
63
-    /** We are a Singleton ! Avoid people to have their own instance. */
64
-    AmSessionContainer();
65
-
66
-    /**
67
-     * Search the container for a session coresponding 
68
-     * to callid and remote_tag. (UAS only).
69
-     *
70
-     * @return the session related to callid & remote_tag
71
-     *         or NULL if none has been found.
72
-     */
73
-    AmSession* getSession(const string& callid, const string& remote_tag);
74
-
75
-    /**
76
-     * Search the container for a session coresponding to local_tag.
77
-     *
78
-     * @return the session related to local_tag 
79
-     *         or NULL if none has been found.
80
-     */
81
-    AmSession* getSession(const string& local_tag);
82
-
83
-    /**
84
-     * Adds a session to the container. (UAS only)
85
-     * @return true if the session is new within the container.
86
-     */
87
-    bool addSession_unsafe(const string& callid, 
88
-			   const string& remote_tag,
89
-			   const string& local_tag,
90
-			   AmSession* session);
91
-
92
-    /**
93
-     * Adds a session to the container.
94
-     * @return true if the session is new within the container.
95
-     */
96
-    bool addSession_unsafe(const string& local_tag,
97
-			   AmSession* session);
98
-
99
-    /**
100
-     * Tries to stop the session and queue it destruction.
101
-     */
102
-    void stopAndQueue(AmSession* s);
103
-
104
-    /** @see AmThread::run() */
105
-    void run();
106
-    /** @see AmThread::on_stop() */
107
-    void on_stop();
54
+  static AmSessionContainer* _SessionContainer;
55
+
56
+  // some typedefs ...
57
+  typedef map<string,AmSession*> SessionMap;
58
+  typedef SessionMap::iterator SessionMapIter;
59
+
60
+  typedef map<string,string>     Dictionnary;
61
+  typedef Dictionnary::iterator  DictIter;
62
+
63
+  typedef queue<AmSession*>      SessionQueue;
64
+
65
+  /** 
66
+   * Container for active sessions 
67
+   * local tag -> session
68
+   */
69
+  SessionMap a_sessions;
70
+
71
+  /** 
72
+   * Call ID + remote tag -> local tag 
73
+   *  (needed for CANCELs and some provisionnal answers)
74
+   *  (UAS sessions only)
75
+   */
76
+  Dictionnary as_id_lookup;
77
+
78
+  /** Mutex to protect the active session container */
79
+  AmMutex    as_mut;
80
+
81
+
82
+  /** Container for dead sessions */
83
+  SessionQueue d_sessions;
84
+  /** Mutex to protect the dead session container */
85
+  AmMutex      ds_mut;
86
+
87
+  /** the daemon only runs if this is true */
88
+  AmCondition<bool> _run_cond;
89
+
90
+  /** We are a Singleton ! Avoid people to have their own instance. */
91
+  AmSessionContainer();
92
+
93
+  /**
94
+   * Search the container for a session coresponding 
95
+   * to callid and remote_tag. (UAS only).
96
+   *
97
+   * @return the session related to callid & remote_tag
98
+   *         or NULL if none has been found.
99
+   */
100
+  AmSession* getSession(const string& callid, const string& remote_tag);
101
+
102
+  /**
103
+   * Search the container for a session coresponding to local_tag.
104
+   *
105
+   * @return the session related to local_tag 
106
+   *         or NULL if none has been found.
107
+   */
108
+  AmSession* getSession(const string& local_tag);
109
+
110
+  /**
111
+   * Adds a session to the container. (UAS only)
112
+   * @return true if the session is new within the container.
113
+   */
114
+  bool addSession_unsafe(const string& callid, 
115
+			 const string& remote_tag,
116
+			 const string& local_tag,
117
+			 AmSession* session);
118
+
119
+  /**
120
+   * Adds a session to the container.
121
+   * @return true if the session is new within the container.
122
+   */
123
+  bool addSession_unsafe(const string& local_tag,
124
+			 AmSession* session);
125
+
126
+  /**
127
+   * Tries to stop the session and queue it destruction.
128
+   */
129
+  void stopAndQueue(AmSession* s);
130
+
131
+  /** @see AmThread::run() */
132
+  void run();
133
+  /** @see AmThread::on_stop() */
134
+  void on_stop();
108 135
 
109 136
  public:
110
-    static AmSessionContainer* instance();
111
-
112
-    /**
113
-     * Creates a new session.
114
-     * @param req local request
115
-     * @return a new session or NULL on error.
116
-     */
117
-    AmSession* createSession(AmSipRequest& req);
118
-
119
-    /**
120
-     * Adds a session to the container (UAS only).
121
-     * @return true if the session is new within the container.
122
-     */
123
-    bool addSession(const string& callid,
124
-		    const string& remote_tag,
125
-		    const string& local_tag,
126
-		    AmSession* session);
127
-
128
-    /**
129
-     * Adds a session to the container.
130
-     * @return true if the session is new within the container.
131
-     */
132
-    bool addSession(const string& local_tag,
133
-		    AmSession* session);
134
-
135
-    /** 
136
-     * Constructs a new session and adds it to the active session container. 
137
-     * @param req client's request
138
-     */
139
-    void startSessionUAS(AmSipRequest& req);
140
-
141
-    /** 
142
-     * Constructs a new session and adds it to the active session container. 
143
-     * @param req client's request
144
-     */
145
-    AmSession* startSessionUAC(AmSipRequest& req);
146
-
147
-    /**
148
-     * Detroys a session.
149
-     */
150
-    void destroySession(AmSession* s);
151
-    void destroySession(const string& local_tag);
152
-
153
-    /**
154
-     * Query the number of active sessions
155
-     */
156
-    int getSize();
157
-
158
-    /**
159
-     * post an event into the event queue of the identified dialog.
160
-     * @return false if session doesn't exist 
161
-     */
162
-    bool postEvent(const string& callid, const string& remote_tag,
163
-		   AmEvent* event);
164
-
165
-    /**
166
-     * post a generic event into the event queue of the identified dialog.
167
-     * sess_key is local_tag (to_tag)
168
-     * note: if hash_str is known, use 
169
-     *          postGenericEvent(hash_str,sess_key,event);
170
-     *       for better performance.
171
-     * @return false if session doesn't exist 
172
-     */
173
-    bool postEvent(const string& local_tag, AmEvent* event);
137
+  static AmSessionContainer* instance();
138
+
139
+  /**
140
+   * Creates a new session.
141
+   * @param req local request
142
+   * @return a new session or NULL on error.
143
+   */
144
+  AmSession* createSession(AmSipRequest& req);
145
+
146
+  /**
147
+   * Adds a session to the container (UAS only).
148
+   * @return true if the session is new within the container.
149
+   */
150
+  bool addSession(const string& callid,
151
+		  const string& remote_tag,
152
+		  const string& local_tag,
153
+		  AmSession* session);
154
+
155
+  /**
156
+   * Adds a session to the container.
157
+   * @return true if the session is new within the container.
158
+   */
159
+  bool addSession(const string& local_tag,
160
+		  AmSession* session);
161
+
162
+  /** 
163
+   * Constructs a new session and adds it to the active session container. 
164
+   * @param req client's request
165
+   */
166
+  void startSessionUAS(AmSipRequest& req);
167
+
168
+  /** 
169
+   * Constructs a new session and adds it to the active session container. 
170
+   * @param req client's request
171
+   */
172
+  AmSession* startSessionUAC(AmSipRequest& req);
173
+
174
+  /**
175
+   * Detroys a session.
176
+   */
177
+  void destroySession(AmSession* s);
178
+  void destroySession(const string& local_tag);
179
+
180
+  /**
181
+   * Query the number of active sessions
182
+   */
183
+  int getSize();
184
+
185
+  /**
186
+   * post an event into the event queue of the identified dialog.
187
+   * @return false if session doesn't exist 
188
+   */
189
+  bool postEvent(const string& callid, const string& remote_tag,
190
+		 AmEvent* event);
191
+
192
+  /**
193
+   * post a generic event into the event queue of the identified dialog.
194
+   * sess_key is local_tag (to_tag)
195
+   * note: if hash_str is known, use 
196
+   *          postGenericEvent(hash_str,sess_key,event);
197
+   *       for better performance.
198
+   * @return false if session doesn't exist 
199
+   */
200
+  bool postEvent(const string& local_tag, AmEvent* event);
174 201
 };
175 202
 
176 203
 #endif
Browse code

removed unneeded function declaration

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@85 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Stefan Sayer authored on 26/09/2006 11:26:50
Showing 1 changed files
... ...
@@ -171,11 +171,6 @@ class AmSessionContainer : public AmThread
171 171
      * @return false if session doesn't exist 
172 172
      */
173 173
     bool postEvent(const string& local_tag, AmEvent* event);
174
-
175
-    /** register a daemon to receive events. 
176
-     *  note: there is no de-registering!!! daemons are to be always there! */
177
-    void registerDaemon(const string& daemon_name, AmEventQueue* event_queue);
178
-
179 174
 };
180 175
 
181 176
 #endif
Browse code

more doxygen documentation

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@84 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Stefan Sayer authored on 25/09/2006 19:45:53
Showing 1 changed files
... ...
@@ -15,7 +15,8 @@ using std::queue;
15 15
 using std::map;
16 16
 
17 17
 /**
18
- * Centralized session container.
18
+ * \brief Centralized session container.
19
+ *
19 20
  * This is the register for all active and dead sessions.
20 21
  * If has a deamon which wakes up only if it has work. 
21 22
  * Then, it kills all dead sessions and try to go to bed 
Browse code

dialout. see AmUAC for API.

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@71 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Stefan Sayer authored on 11/09/2006 15:21:00
Showing 1 changed files
... ...
@@ -133,12 +133,16 @@ class AmSessionContainer : public AmThread
133 133
 
134 134
     /** 
135 135
      * Constructs a new session and adds it to the active session container. 
136
-     * @param hash_str Call-ID + remote-tag
137
-     * @param sess_key local-tag
138 136
      * @param req client's request
139 137
      */
140 138
     void startSessionUAS(AmSipRequest& req);
141 139
 
140
+    /** 
141
+     * Constructs a new session and adds it to the active session container. 
142
+     * @param req client's request
143
+     */
144
+    AmSession* startSessionUAC(AmSipRequest& req);
145
+
142 146
     /**
143 147
      * Detroys a session.
144 148
      */
Browse code

initial checkin new open source version.

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@5 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Raphael Coeffic authored on 17/03/2006 13:16:06
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,176 @@
1
+#ifndef AmSessionContainer_h
2
+#define AmSessionContainer_h
3
+
4
+#include "AmThread.h"
5
+#include "AmSession.h"
6
+
7
+#include <string>
8
+#include <vector>
9
+#include <queue>
10
+#include <map>
11
+
12
+using std::string;
13
+using std::vector;
14
+using std::queue;
15
+using std::map;
16
+
17
+/**
18
+ * Centralized session container.
19
+ * This is the register for all active and dead sessions.
20
+ * If has a deamon which wakes up only if it has work. 
21
+ * Then, it kills all dead sessions and try to go to bed 
22
+ * (it cannot sleep if one or more sessions are still alive).
23
+ */
24
+class AmSessionContainer : public AmThread
25
+{
26
+    static AmSessionContainer* _SessionContainer;
27
+
28
+    // some typedefs ...
29
+    typedef map<string,AmSession*> SessionMap;
30
+    typedef SessionMap::iterator SessionMapIter;
31
+
32
+    typedef map<string,string>     Dictionnary;
33
+    typedef Dictionnary::iterator  DictIter;
34
+
35
+    typedef queue<AmSession*>      SessionQueue;
36
+
37
+    /** 
38
+     * Container for active sessions 
39
+     * local tag -> session
40
+     */
41
+    SessionMap a_sessions;
42
+
43
+    /** 
44
+     * Call ID + remote tag -> local tag 
45
+     *  (needed for CANCELs and some provisionnal answers)
46
+     *  (UAS sessions only)
47
+     */
48
+    Dictionnary as_id_lookup;
49
+
50
+    /** Mutex to protect the active session container */
51
+    AmMutex    as_mut;
52
+
53
+