act on SystemEvent::ServerShutdown

TODO: wait until contacts are really deregistered (resent with uac) or shutdown



git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1088 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 18 years ago
parent d9884e05d1
commit 8273149b35

@ -197,7 +197,8 @@ SIPRegistrarClient* SIPRegistrarClient::instance()
SIPRegistrarClient::SIPRegistrarClient(const string& name)
: AmEventQueue(this),
uac_auth_i(NULL),
AmDynInvokeFactory(MOD_NAME)
AmDynInvokeFactory(MOD_NAME),
stop_requested(false)
{
}
@ -211,7 +212,7 @@ void SIPRegistrarClient::run() {
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 @@ int SIPRegistrarClient::onLoad() {
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 @@ void SIPRegistrarClient::process(AmEvent* ev) {
return;
}
}
void SIPRegistrarClient::onSipReplyEvent(AmSipReplyEvent* ev) {

@ -167,8 +167,9 @@ class SIPRegistrarClient : public AmThread,
AmDynInvoke* uac_auth_i;
AmSharedVar<bool> stop_requested;
void checkTimeouts();
void onServerShutdown();
public:
SIPRegistrarClient(const string& name);
// DI factory

Loading…
Cancel
Save