If hang up at Bridge

Hi,

I’m doing the live session of two channels. And I use Bridge to connect two channels. Everything works well but only one problem. If one of them or both of them hang up directly at Bridge, instead of pressing ‘#’ key to end the live, I cannot get the duration of their live session to update their status and call logs .

Code in features.conf:

[applicationmap] exitbyself=>#,self/caller,macro,disconnectlive exitbyparty=>#,peer/callee,macro,disconnectlive
Some code of connection:

Once two channels are connected, the caller channel will be changed to a Zombie channel, for example “SIP/123456-000001” will be changed to “Bridge/SIP/123456-000001”. And this Zombie channel will run the code below:

exten => h,1(mainhangup),NoOp(--------------------Hangup--------------------) exten => h,n,Gotoif($["${CHANNEL:0:6}" = "Bridge"]?hangup) exten => h,n(hangup),hangup()
If they end the live by pressing “#” key, their channels will be redirect to livecomplete, and I will count their live duration.

[macro-disconnectlive] exten => s,1,NoOp(!!!!!!!!!!!!!!!!!!!partychannel: ${partychannel}!!!!!!!!!!!!!!!!!!!!!!!) exten => s,n,NoOp(!!!!!!!!!!!!!!!!!!!CHANNEL: ${CHANNEL}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) exten => s,n,Set(c1=${CHANNEL}) exten => s,n,NoOp(!!!!!!!!!!!!!!!!!partyusername: ${partyusername}!!!!!!!!!!!!!!!!!!!!!) exten => s,n,Execif($["${partychannel}"=""]?Set(partychannel=${${cap}liveonline_getchannel(${partyusername})})) exten => s,n,NoOp(~ ~ ~ ~ ~ ~ ~ ~ ${partychannel} ~ ~ ~ ~ ~ ~ ~) exten => s,n,Execif($["${poke}"="y"]?ChannelRedirect(SIP/${partyusername},livechat,h,hangup):ChannelRedirect(${partychannel},livechat,s,livecomplete)) exten => s,n,ChannelRedirect(${c1},livechat,s,livecomplete)

;livecomplete exten => s,n(livecomplete),NoOp( ~ ~ ~ ~ ~ live complete ~ ~ ~ ~ ~ ) exten => s,n,ControlPlayback(${ichat}/liveprompts/${Lang}/livesessionend,,,,1||2||3||4||5||6||7||8||9||0||*||#) exten => s,n,Set(Sliveonline_update(status)=online) exten => s,n,AGI(livesession_update_Live.agi,${Username},${partyusername},${refno},${lsid},${cap}) exten => s,n,Set(${cap}request_updatelive(channel_usr2)=${CHANNEL}) exten => s,n,Set(${cap}request_updatelive(ServNum_usr2)=${servicenum}) exten => s,n,Set(${cap}request_update(progress)=complete) exten => s,n,Set(totalsecs=${Srequest_checkdursecs()})) exten => s,n,Set(${cap}liveonline_update(status)=online) exten => s,n,Set(GLOBAL(poke)=n) exten => s,n,NoOp(^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ${partyusername} ^ ^ ^ ^ ^ ^ ^ ^ ^ ^) exten => s,n(completemenu),Read(cmopt,${ichat}/liveprompts/${Lang}/completemenu,1,,3,4)

But if the caller hang up directly after talking, I cannot get anything data of their live session. And all data of the caller cannot be updated. When I use write code to check the caller’s original channel on callee side, it said there is no such channel.
So far I only can count the live duration on callee side to update their data. But if callee hang up first, what can I do ?

Is it possible that reconvert zombie channel to the original channel after caller hang up at bridge?

Can anybody help me? Or does anybody have a better way to solve it?

Thanks a lot!!!

As already noted: the use of Macro in that context is not supported, so done at your own risk; ChannelRedirect takes a channel name, not a dial string; and your h extension does nothing useful as an h extension, and is confusing when you jump to the last line from elsewhere;