Author: sayer
Date: 2008-09-23 21:05:18 +0200 (Tue, 23 Sep 2008)
New Revision: 1088
Modified:
trunk/apps/registrar_client/SIPRegistrarClient.cpp
trunk/apps/registrar_client/SIPRegistrarClient.h
Log:
act on SystemEvent::ServerShutdown
TODO: wait until contacts are really deregistered (resent with uac) or shutdown
Modified: trunk/apps/registrar_client/SIPRegistrarClient.cpp
===================================================================
--- trunk/apps/registrar_client/SIPRegistrarClient.cpp 2008-09-23 19:03:46 UTC
(rev 1087)
+++ trunk/apps/registrar_client/SIPRegistrarClient.cpp 2008-09-23 19:05:18 UTC
(rev 1088)
@@ -197,7 +197,8 @@
SIPRegistrarClient::SIPRegistrarClient(const string& name)
: AmEventQueue(this),
uac_auth_i(NULL),
- AmDynInvokeFactory(MOD_NAME)
+ AmDynInvokeFactory(MOD_NAME),
+ stop_requested(false)
{
}
@@ -211,7 +212,7 @@
uac_auth_i = uac_auth_f->getInstance();
}
- while (true) {
+ while (!stop_requested.get()) {
if (registrations.size()) {
unsigned int cnt = 250;
while (cnt > 0) {
@@ -294,7 +295,33 @@
return 0;
}
+void SIPRegistrarClient::onServerShutdown() {
+ // TODO: properly wait until unregistered, with timeout
+ DBG("shutdown SIP registrar client: deregistering\n");
+ for (std::map<std::string, SIPRegistration*>::iterator it=
+ registrations.begin(); it != registrations.end(); it++) {
+ it->second->doUnregister();
+ AmEventDispatcher::instance()->delEventQueue(it->first);
+ }
+
+ stop_requested.set(true);
+//
+// setStopped();
+// return;
+}
+
void SIPRegistrarClient::process(AmEvent* ev) {
+ if (ev->event_id == E_SYSTEM) {
+ AmSystemEvent* sys_ev = dynamic_cast<AmSystemEvent*>(ev);
+ if(sys_ev){
+ DBG("Session received system Event\n");
+ if (sys_ev->sys_event == AmSystemEvent::ServerShutdown) {
+ onServerShutdown();
+ }
+ return;
+ }
+ }
+
AmSipReplyEvent* sip_rep = dynamic_cast<AmSipReplyEvent*>(ev);
if (sip_rep) {
onSipReplyEvent(sip_rep);
@@ -313,6 +340,7 @@
return;
}
+
}
void SIPRegistrarClient::onSipReplyEvent(AmSipReplyEvent* ev) {
Modified: trunk/apps/registrar_client/SIPRegistrarClient.h
===================================================================
--- trunk/apps/registrar_client/SIPRegistrarClient.h 2008-09-23 19:03:46 UTC
(rev 1087)
+++ trunk/apps/registrar_client/SIPRegistrarClient.h 2008-09-23 19:05:18 UTC
(rev 1088)
@@ -167,8 +167,9 @@
AmDynInvoke* uac_auth_i;
-
+ AmSharedVar<bool> stop_requested;
void checkTimeouts();
+ void onServerShutdown();
public:
SIPRegistrarClient(const string& name);
// DI factory
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev