generate event on asterisk dialplan if any user left confbridge

1.4k views Asked by At

I am using confBridge in my asterisk for conferencing. I want to detect if number of user remain less than or equal to 1 in ongoing call then terminate the conference call.

I have tried this-

exten => ConfTest,1,System(asterisk -rx "confbridge kick ${DB(CONF/NUM)} ${DB(CONF/ConfTest)}")
exten => ConfTest,n,Set(DB(CONF/ConfTest)=${CHANNEL})
exten => ConfTest,n,Set(ID=${RAND(1,500)})
exten => ConfTest,n,Set(DB(CONF/NUM)=${ID})
exten => ConfTest,n,Set(target=ConfTest1)
exten => ConfTest,n,Originate(SIP/${target},app,confBridge,${ID},default_user)
exten => ConfTest,n,Set(target=ConfTest2)
exten => ConfTest,n,Originate(SIP/${target},app,confBridge,${ID},default_user)
exten => ConfTest,n,Macro(dialout-trunk-predial-hook-test)
exten => ConfTest,n,confbridge(${ID},,src_user)
exten => ConfTest,n,Answer()
exten => ConfTest,n,Set(i=1)
exten => ConfTest,n,While($[${i} = 1])
exten => ConfTest,n,GoToIf($[0${CONFBRIDGE_INFO(parties,${ID})} <= 1]?18:15)
exten => ConfTest,n,NoOp(number of participants in conference call = ${CONFBRIDGE_INFO(parties,${ID})})
exten => ConfTest,n,Wait(1000)
exten => ConfTest,n,EndWhile()
exten => ConfTest,n,System(asterisk -rx "confbridge kick ${DB(CONF/NUM)} ${DB(CONF/ConfTest))

here lines are not executing from while loop.

Is there any thing available to register hangup handler for all the channel involve in conference call. For example-

debianpc08*CLI> confbridge list 1
Channel                       User Profile     Bridge Profile   Menu             CallerID
============================= ================ ================ ================ ================
SIP/ConfTest1-0000009c        default_user     default_bridge                    ConfTest1
SIP/ConfTest2-0000009d        default_user     default_bridge                    ConfTest2
SIP/ConfTest3-0000009b        src_user         default_bridge                    ConfTest3

here i want to register hangup handler for all the channels like SIP/ConfTest1-0000009c.

2

There are 2 answers

0
arheops On

You can use default hangup handler(h-extension) to catch that

;record situation
exten => ConfTest,n,Set(HANGUP_OK=NO)
exten => ConfTest,n,confbridge(${ID},,src_user)
; if user exit confbridge, clear it
exten => ConfTest,n,Set(HANGUP_OK=YES)

; if hanguped in confbridge, do something
exten => h,1,GotoIF($[ "${HANGUP_OK}" == "NO" ]?dosomething,s,1)
0
Nir Simionovich On

You are going the wrong about it. Your best choice for this task would be to use Asterisk ARI and the bridges API. The idea will be very simple, initiate a Stasis application to handle your bridge, put the channels into the bridge. As they come in and out of the bridge, listen to the WebSocket events to see who left and who came in.

You can have a look at http://www.phpari.org for additional information on how to write such an application, the demo dial application should give you ample information on how to do it.

Nir