Added more flexible timer check method in Channel.
git-svn-id: http://yate.null.ro/svn/yate/trunk@708 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
2e625f110d
commit
5bc59150e3
|
@ -512,6 +512,14 @@ void Channel::statusParams(String& str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Channel::checkTimers(Message& msg, const Time& tmr)
|
||||||
|
{
|
||||||
|
if (timeout() && (timeout() < tmr))
|
||||||
|
msgDrop(msg,"timeout");
|
||||||
|
else if (maxcall() && (maxcall() < tmr))
|
||||||
|
msgDrop(msg,"noanswer");
|
||||||
|
}
|
||||||
|
|
||||||
bool Channel::callPrerouted(Message& msg, bool handled)
|
bool Channel::callPrerouted(Message& msg, bool handled)
|
||||||
{
|
{
|
||||||
status("prerouted");
|
status("prerouted");
|
||||||
|
@ -885,6 +893,7 @@ bool Driver::received(Message &msg, int id)
|
||||||
unlock();
|
unlock();
|
||||||
if (!c)
|
if (!c)
|
||||||
break;
|
break;
|
||||||
|
c->checkTimers(msg,t);
|
||||||
if (c->timeout() && (c->timeout() < t))
|
if (c->timeout() && (c->timeout() < t))
|
||||||
c->msgDrop(msg,"timeout");
|
c->msgDrop(msg,"timeout");
|
||||||
else if (c->maxcall() && (c->maxcall() < t))
|
else if (c->maxcall() && (c->maxcall() < t))
|
||||||
|
|
|
@ -133,11 +133,14 @@ public:
|
||||||
virtual bool callRouted(Message& msg);
|
virtual bool callRouted(Message& msg);
|
||||||
virtual bool msgRinging(Message& msg);
|
virtual bool msgRinging(Message& msg);
|
||||||
virtual bool msgAnswered(Message& msg);
|
virtual bool msgAnswered(Message& msg);
|
||||||
|
virtual void checkTimers(Message& msg, const Time& tmr);
|
||||||
void startChannel(NamedList& params);
|
void startChannel(NamedList& params);
|
||||||
void addSource();
|
void addSource();
|
||||||
void addConsumer();
|
void addConsumer();
|
||||||
protected:
|
protected:
|
||||||
|
void setDuration(NamedList& params);
|
||||||
void localParams(String& str);
|
void localParams(String& str);
|
||||||
|
u_int64_t m_stopTime;
|
||||||
u_int64_t m_timeStart;
|
u_int64_t m_timeStart;
|
||||||
unsigned long m_timeRoute;
|
unsigned long m_timeRoute;
|
||||||
unsigned long m_timeRing;
|
unsigned long m_timeRing;
|
||||||
|
@ -537,7 +540,7 @@ void AnalyzerCons::statusParams(String& str)
|
||||||
|
|
||||||
|
|
||||||
AnalyzerChan::AnalyzerChan(const String& type, bool outgoing, const char* window)
|
AnalyzerChan::AnalyzerChan(const String& type, bool outgoing, const char* window)
|
||||||
: Channel(__plugin,0,outgoing),
|
: Channel(__plugin,0,outgoing), m_stopTime(0),
|
||||||
m_timeStart(Time::now()), m_timeRoute(0), m_timeRing(0), m_timeAnswer(0),
|
m_timeStart(Time::now()), m_timeRoute(0), m_timeRing(0), m_timeAnswer(0),
|
||||||
m_window(window)
|
m_window(window)
|
||||||
{
|
{
|
||||||
|
@ -591,6 +594,7 @@ bool AnalyzerChan::callRouted(Message& msg)
|
||||||
{
|
{
|
||||||
if (!m_timeRoute)
|
if (!m_timeRoute)
|
||||||
m_timeRoute = Time::now() - m_timeStart;
|
m_timeRoute = Time::now() - m_timeStart;
|
||||||
|
setDuration(msg);
|
||||||
return Channel::callRouted(msg);
|
return Channel::callRouted(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,6 +614,14 @@ bool AnalyzerChan::msgAnswered(Message& msg)
|
||||||
return Channel::msgAnswered(msg);
|
return Channel::msgAnswered(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AnalyzerChan::checkTimers(Message& msg, const Time& tmr)
|
||||||
|
{
|
||||||
|
if (m_stopTime && (m_stopTime < tmr))
|
||||||
|
msgDrop(msg,"finished");
|
||||||
|
else
|
||||||
|
Channel::checkTimers(msg,tmr);
|
||||||
|
}
|
||||||
|
|
||||||
void AnalyzerChan::startChannel(NamedList& params)
|
void AnalyzerChan::startChannel(NamedList& params)
|
||||||
{
|
{
|
||||||
Message* m = message("chan.startup");
|
Message* m = message("chan.startup");
|
||||||
|
@ -629,6 +641,14 @@ void AnalyzerChan::startChannel(NamedList& params)
|
||||||
addConsumer();
|
addConsumer();
|
||||||
addSource();
|
addSource();
|
||||||
}
|
}
|
||||||
|
setDuration(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnalyzerChan::setDuration(NamedList& params)
|
||||||
|
{
|
||||||
|
int t = params.getIntValue("duration",120000);
|
||||||
|
if (t > 0)
|
||||||
|
m_stopTime = Time::now() + 1000 * (uint64_t)t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnalyzerChan::addSource()
|
void AnalyzerChan::addSource()
|
||||||
|
|
|
@ -1276,6 +1276,13 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void msgStatus(Message& msg);
|
virtual void msgStatus(Message& msg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timer check method, by default handles channel timeouts
|
||||||
|
* @param msg Timer message
|
||||||
|
* @param tmr Current time against which timers are compared
|
||||||
|
*/
|
||||||
|
virtual void checkTimers(Message& msg, const Time& tmr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notification on progress of prerouting incoming call
|
* Notification on progress of prerouting incoming call
|
||||||
* @param msg Notification call.preroute message just after being dispatched
|
* @param msg Notification call.preroute message just after being dispatched
|
||||||
|
|
Loading…
Reference in New Issue