Added parameter "queuetime" for the CDR builder to know how long a call waited in a queue.
All calls in a queue can be dropped by specifying queuename/* as id. A call to a "single" type queue is dropped when its operator call fails. git-svn-id: http://yate.null.ro/svn/yate/trunk@2795 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
6fafa9bf1e
commit
05ef31e6b7
|
@ -5,7 +5,7 @@
|
||||||
;account=
|
;account=
|
||||||
|
|
||||||
; priority: int: Default priority of message handlers, 0 to disable them
|
; priority: int: Default priority of message handlers, 0 to disable them
|
||||||
;priority=50
|
;priority=45
|
||||||
|
|
||||||
; rescan: int: Period of polling for available operators, in seconds
|
; rescan: int: Period of polling for available operators, in seconds
|
||||||
;rescan=5
|
;rescan=5
|
||||||
|
|
|
@ -65,10 +65,12 @@ public:
|
||||||
{ return m_calls.count(); }
|
{ return m_calls.count(); }
|
||||||
inline QueuedCall* findCall(const String& id) const
|
inline QueuedCall* findCall(const String& id) const
|
||||||
{ return static_cast<QueuedCall*>(m_calls[id]); }
|
{ return static_cast<QueuedCall*>(m_calls[id]); }
|
||||||
|
inline QueuedCall* findCall(unsigned int index) const
|
||||||
|
{ return static_cast<QueuedCall*>(m_calls[index]); }
|
||||||
bool addCall(Message& msg);
|
bool addCall(Message& msg);
|
||||||
inline bool removeCall(const String& id, const char* reason)
|
inline int removeCall(const String& id, const char* reason)
|
||||||
{ return removeCall(findCall(id),reason); }
|
{ return removeCall(findCall(id),reason); }
|
||||||
bool removeCall(QueuedCall* call, const char* reason);
|
int removeCall(QueuedCall* call, const char* reason);
|
||||||
QueuedCall* markCall(const char* mark);
|
QueuedCall* markCall(const char* mark);
|
||||||
bool unmarkCall(const String& id);
|
bool unmarkCall(const String& id);
|
||||||
void countCalls(unsigned int& marked, unsigned int& unmarked) const;
|
void countCalls(unsigned int& marked, unsigned int& unmarked) const;
|
||||||
|
@ -113,7 +115,7 @@ protected:
|
||||||
void onHangup(Message& msg, String id);
|
void onHangup(Message& msg, String id);
|
||||||
void onQueued(Message& msg, String qname);
|
void onQueued(Message& msg, String qname);
|
||||||
void onPickup(Message& msg, String qname);
|
void onPickup(Message& msg, String qname);
|
||||||
void onDrop(Message& msg, String qname);
|
bool onDrop(Message& msg, String qname);
|
||||||
private:
|
private:
|
||||||
bool m_init;
|
bool m_init;
|
||||||
};
|
};
|
||||||
|
@ -298,10 +300,11 @@ bool CallsQueue::addCall(Message& msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove and destroy call from the queue, destroy the queue if it becomes empty
|
// Remove and destroy call from the queue, destroy the queue if it becomes empty
|
||||||
bool CallsQueue::removeCall(QueuedCall* call, const char* reason)
|
int CallsQueue::removeCall(QueuedCall* call, const char* reason)
|
||||||
{
|
{
|
||||||
if (!call)
|
if (!call)
|
||||||
return false;
|
return -1;
|
||||||
|
int waited = (call->waitingTime() + 500000) / 1000000;
|
||||||
notify(reason,call);
|
notify(reason,call);
|
||||||
int pos = m_detail ? position(call) : -1;
|
int pos = m_detail ? position(call) : -1;
|
||||||
m_calls.remove(call);
|
m_calls.remove(call);
|
||||||
|
@ -315,7 +318,7 @@ bool CallsQueue::removeCall(QueuedCall* call, const char* reason)
|
||||||
notify("position",c);
|
notify("position",c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return waited;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark a call as being routed to an operator
|
// Mark a call as being routed to an operator
|
||||||
|
@ -340,6 +343,10 @@ bool CallsQueue::unmarkCall(const String& id)
|
||||||
return false;
|
return false;
|
||||||
if (m_single) {
|
if (m_single) {
|
||||||
removeCall(call,"noanswer");
|
removeCall(call,"noanswer");
|
||||||
|
Message* m = new Message("call.drop");
|
||||||
|
m->addParam("id",id);
|
||||||
|
m->addParam("reason","noanswer");
|
||||||
|
Engine::enqueue(m);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
call->setMarked();
|
call->setMarked();
|
||||||
|
@ -568,7 +575,7 @@ void QueuesModule::onPickup(Message& msg, String qname)
|
||||||
if (call) {
|
if (call) {
|
||||||
id = *call;
|
id = *call;
|
||||||
String pid = msg.getValue("id");
|
String pid = msg.getValue("id");
|
||||||
queue->removeCall(call,"pickup");
|
String waited(queue->removeCall(call,"pickup"));
|
||||||
// convert message and let it connect to the queued call
|
// convert message and let it connect to the queued call
|
||||||
msg = "chan.connect";
|
msg = "chan.connect";
|
||||||
msg.setParam("targetid",id);
|
msg.setParam("targetid",id);
|
||||||
|
@ -581,6 +588,7 @@ void QueuesModule::onPickup(Message& msg, String qname)
|
||||||
m = new Message("call.answered");
|
m = new Message("call.answered");
|
||||||
m->setParam("id",id);
|
m->setParam("id",id);
|
||||||
m->setParam("targetid",pid);
|
m->setParam("targetid",pid);
|
||||||
|
m->setParam("queuetime",waited);
|
||||||
Engine::enqueue(m);
|
Engine::enqueue(m);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -608,7 +616,11 @@ void QueuesModule::onAnswered(Message& msg, String targetid, String reason)
|
||||||
return;
|
return;
|
||||||
Debug(this,DebugCall,"Answered call '%s' in queue '%s'",
|
Debug(this,DebugCall,"Answered call '%s' in queue '%s'",
|
||||||
targetid.c_str(),queue->c_str());
|
targetid.c_str(),queue->c_str());
|
||||||
queue->removeCall(targetid,"answered");
|
String waited(queue->removeCall(targetid,"answered"));
|
||||||
|
Message* m = new Message("call.update");
|
||||||
|
m->addParam("id",targetid);
|
||||||
|
m->addParam("queuetime",waited);
|
||||||
|
Engine::enqueue(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle hangups on either caller or operator
|
// Handle hangups on either caller or operator
|
||||||
|
@ -637,10 +649,10 @@ void QueuesModule::onHangup(Message& msg, String id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop the call from the head of a queue or a call specified by ID
|
// Drop the call from the head of a queue or a call specified by ID
|
||||||
void QueuesModule::onDrop(Message& msg, String qname)
|
bool QueuesModule::onDrop(Message& msg, String qname)
|
||||||
{
|
{
|
||||||
if (qname.null())
|
if (qname.null())
|
||||||
return;
|
return false;
|
||||||
String id;
|
String id;
|
||||||
int sep = qname.find('/');
|
int sep = qname.find('/');
|
||||||
if (sep >= 0) {
|
if (sep >= 0) {
|
||||||
|
@ -649,6 +661,20 @@ void QueuesModule::onDrop(Message& msg, String qname)
|
||||||
}
|
}
|
||||||
CallsQueue* queue = findQueue(qname);
|
CallsQueue* queue = findQueue(qname);
|
||||||
if (queue) {
|
if (queue) {
|
||||||
|
if (id == "*") {
|
||||||
|
const char* reason = msg.getValue("reason");
|
||||||
|
for (unsigned int i = 0; ; i++) {
|
||||||
|
QueuedCall* call = queue->findCall(i);
|
||||||
|
if (!call)
|
||||||
|
break;
|
||||||
|
Message* m = new Message("call.drop");
|
||||||
|
m->addParam("id",*call);
|
||||||
|
if (reason)
|
||||||
|
m->addParam("reason",reason);
|
||||||
|
Engine::enqueue(m);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
QueuedCall* call = id ? queue->findCall(id) : queue->topCall();
|
QueuedCall* call = id ? queue->findCall(id) : queue->topCall();
|
||||||
if (call) {
|
if (call) {
|
||||||
id = *call;
|
id = *call;
|
||||||
|
@ -657,6 +683,7 @@ void QueuesModule::onDrop(Message& msg, String qname)
|
||||||
msg.setParam("id",id);
|
msg.setParam("id",id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command line execute handler
|
// Command line execute handler
|
||||||
|
@ -696,8 +723,7 @@ bool QueuesModule::received(Message& msg, int id)
|
||||||
onHangup(msg,msg.getValue("id"));
|
onHangup(msg,msg.getValue("id"));
|
||||||
break;
|
break;
|
||||||
case Drop:
|
case Drop:
|
||||||
onDrop(msg,msg.getValue("id"));
|
return onDrop(msg,msg.getValue("id"));
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
lock.drop();
|
lock.drop();
|
||||||
return Module::received(msg,id);
|
return Module::received(msg,id);
|
||||||
|
@ -752,7 +778,7 @@ void QueuesModule::initialize()
|
||||||
return;
|
return;
|
||||||
m_init = true;
|
m_init = true;
|
||||||
setup();
|
setup();
|
||||||
int priority = s_cfg.getIntValue("general","priority",50);
|
int priority = s_cfg.getIntValue("general","priority",45);
|
||||||
installRelay(Execute,s_cfg.getIntValue("priorities","call.execute",priority));
|
installRelay(Execute,s_cfg.getIntValue("priorities","call.execute",priority));
|
||||||
installRelay(Answered,s_cfg.getIntValue("priorities","call.answered",priority));
|
installRelay(Answered,s_cfg.getIntValue("priorities","call.answered",priority));
|
||||||
installRelay(Private,"chan.hangup",s_cfg.getIntValue("priorities","chan.hangup",priority));
|
installRelay(Private,"chan.hangup",s_cfg.getIntValue("priorities","chan.hangup",priority));
|
||||||
|
|
Loading…
Reference in New Issue