Summary:ASTERISK-05075: ${AGENTBYCALLERID_${CALLERID} isn't updated when a logged in agent logs in again
Reporter:Alan Ferrency (ferrency)Labels:
Date Opened:2005-09-13 13:23:41Date Closed:2008-01-15 15:47:59.000-0600
Versions:Frequency of
Description:Mantis ASTERISK-4499 fixes many cases of AGENTBYCALLERID variables not being reset when they should be, but one case was missed.

When an agent who is logged in via AgentCallbackLogin logs in again via AgentCallbackLogin without logging out first, the old extension's AGENTBYCALLERID variable is not reset.

The fix for this seems simple, though I don't have a complete understanding of chan_agent: action_agent_callback_login should check if the agent is already logged in, and if so, clear out the AGENTBYCALLERID variable for the agent's old extension prior to setting up the agent's new caller ID.


I use AGENTBYCALLERID to prevent multiple agents from logging in to the same extension.  To do this, I need to know whether someone is logged in to the current extension or not.  

Here is a snippet of extensions.conf which does this:


exten => 512, 1, noop(agent login ${CALLERID}, ${CALLERIDNUM})
exten => 512, 2, macro(agent_login,${CALLERID},${CALLERIDNUM})
exten => 513, 1, macro(agent_logout_ext,${CALLERIDNUM})


; Agent login.

; If someone is already logged in to this extension, then turn this
; into an agent logout.  Otherwise, log in: we only prompt for agent
; ID, and we don't use passwords.
; ${ARG1} is the full caller ID of the extension the agent will be
; logged in to.
; ${ARG2} is the CALLERIDNUM of the extension the agent will be logged
; in to.

; If there's an agent set for this callerid, then log it out;
; otherwise, log in.
exten => s, 1, set(agent=${AGENTBYCALLERID_${ARG2}})
exten => s, 2, gotoif(${agent}?104:9)

exten => s, 9, noop(Agent: ${agent} ${AGENTBYCALLERID_${ARG2}})
exten => s, 10, agentcallbacklogin(,${ARG2}@shared_phones)

; Agent is logged in.  log them out?
exten => s, 104, goto(agent_logged_in,s,1)

exten => s, 1, macro(answer_wait)
exten => s, 2, background(pair/allison/agent-logged-in)
exten => s, 3, background(press-1)
exten => s, 4, background(pair/allison/stay-logged-in)

exten => 1, 1, macro(agent_logout,${agent})
; this hangs up

exten => _[2-9#*], 1, playback(goodbye)
exten => _[2-9#*], 2, hangup


; Agent logout.
; Log out the specified agent.
; On a logged-in agent phone, caller ID is set to the agent's caller
; ID automatically, so we don't need to look up the agent ID for this
; caller ID.

exten => s, 1, setglobalvar(agent=${ARG1})
exten => s, 2, noop(agent ${agent})
exten => s, 3, dial(local/logout@macro-agent_logout/n,,D(w#)o)

exten => logout, 1, noop(agent logout ${agent})
exten => logout, 2, wait(1)
exten => logout, 3, agentcallbacklogin(${agent},@shared_phones)

When an agent logs in at two extensions successively, subsequent logoff attempts   at the first extension fail, which is correct since no one is logged in.  But AGENTBYCALLERID is still populated, so the agent login macro also fails.
Comments:By: Kevin P. Fleming (kpfleming) 2005-09-13 20:40:54

Thank you for the clear and concise issue report :-) This should be fixed in CVS HEAD now.

By: Digium Subversion (svnbot) 2008-01-15 15:47:59.000-0600

Repository: asterisk
Revision: 6575

U   trunk/channels/chan_agent.c

r6575 | kpfleming | 2008-01-15 15:47:59 -0600 (Tue, 15 Jan 2008) | 2 lines

ensure that the AGENTBYCALLERID_* variable is cleared when an agent logs in to a different device (issue ASTERISK-5075)