Example #1
0
// remove timeouted and unconfirmed calls
// must be locked;
void CallManager::MaintainCalls(Connection *sqlCon)
{
	for (size_t i=0; i<calls.size(); i++) {
		Call *call = calls[i];
		if (PhoneCall *pcall = dynamic_cast<PhoneCall *>(call))
			if ((call->getState() == ACTIVE && call->getStartTime() + SessionManager::getOptions().Timeout_CallStatus < time(0)) ||
					(pcall->getState() == AWAIT && pcall->getRequestTime() + SessionManager::getOptions().Timeout_CallRequest < time(0)) ||
					(pcall->getState() == CONFIRMED && pcall->getConfirmTime() + SessionManager::getOptions().Timeout_CallConfirm < time(0))) {
				log(LOG_VERBOSE, "MaintainCalls: deleting call %d[%d->%d] with timeouted confirmation.", call->getID(), call->getClient(), call->getTranslator());
				call->sendTimeouts();
				EndCall(sqlCon, call->getID());
			}
	}
}