I got a brilliant idea (i know ) that challenge could be solved by use of shared variable where endopoint would share a variable with itself, not with full channel name, but with prefix only.
Theory:
Endpoint SIP/XXXX answers a queue call on channel SIP/XXXX-YYYYYYYY and has a variable FROMQ=true. Based on that, in Dial U subroutine, it creates a shared variable SHARED(FROMQ, SIP/XXXX)=true.
so… when the same endpoint puts existing incoming queue call on hold and tries to do an attended transfer, I wait for that new, fresh, parallel call from same endpoint in Dial B subroutine, channel SIP/XXXX-ZZZZZZZZ, where I check for presence of SHARED(FROMQ, SIP/XXXX)=true. If it’s present, then do __FROMQ=true for that new channel so the var will be inhertied to the new channel.
Real life:
It doesn’t work in 90% of cases and I don’t understand why (bear with me, I am just a padawan). My first thought was that shared variable gets destroyed before used on outbound call (part of attended transfer), but first call is still there (on hold), which is also seen in call log.
Maybe I am using the shared function with prefixes wrong? Or misunderstand how it’s supposed to work?
Dialplan part of Dial U subroutine:
exten => s,n,ExecIf($[“${CHANNEL:0:3}” = “SIP” & “${FROMQ}” = “true”]?Set(SHARED(ECHOFROMQ,${CUT(CHANNEL,-,1)})=true))
Call log part of Dial U subroutine:
-- Executing [s@UDIAL:9] ExecIf("SIP/1002-00000144", "1?Set(SHARED(ECHOFROMQ,SIP/1002)=true)") in new stack
-- Executing [s@UDIAL:10] NoOp("SIP/1002-00000144", "SHAREDECHOFROMQ is true") in new stack
Dialplan part of dial B subroutine:
exten => s,n,NoOp(CUT CHANNEL is ${CUT(CHANNEL,-,1)})
exten => s,n,NoOp(SHAREDFROMQ is ${SHARED(ECHOFROMQ,${CUT(CHANNEL,-,1)})})
exten => s,n,DumpChan()
exten => s,n,ExecIf($[“${CHANNEL:0:3}” = “SIP” & “${SHARED(ECHOFROMQ,${CUT(CHANNEL,-,1)})}” = “true”]?Set(__FROMQ=true))
Call log part of Dial B subroutine:
– Executing [s@BDIAL:1] NoOp(“SIP/1002-00000145”, “BDIAL”) in new stack
– Executing [s@BDIAL:2] NoOp(“SIP/1002-00000145”, “CHANNEL is SIP/1002-00000145”) in new stack
– Executing [s@BDIAL:3] NoOp(“SIP/1002-00000145”, “MASTER CHANNEL is SIP/1002-00000145”) in new stack
– Executing [s@BDIAL:4] NoOp(“SIP/1002-00000145”, "FROMQ is ") in new stack
– Executing [s@BDIAL:5] NoOp(“SIP/1002-00000145”, “CUT CHANNEL is SIP/1002”) in new stack
– Executing [s@BDIAL:6] NoOp(“SIP/1002-00000145”, "SHAREDFROMQ is ") in new stack
– Executing [s@BDIAL:7] DumpChan(“SIP/1002-00000145”, “”) in new stack
– Executing [s@BDIAL:8] ExecIf(“SIP/1002-00000145”, “0?Set(__FROMQ=true)”) in new stack
Can anyone shed some light on that?
(I hope I used endpoint and extension expressions right this time. )
Big thanks in advance.
Andrej