Hi,
I am wondering if it is possible to handle a hang-up event. I have a database that tracks who is in a certain ConfBridge room, ie: presence. I wrote webservices that are consumed by my client app to know who is online and not. There is also access control to see if someone is allowed to join a room.
Now, what I’d like to do is update the record in the database once the user hangs up from within ConfBridge.
Here is my extension code
/etc/asterisk/extensions.conf
{…}
[users]
exten => _X!,1,Answer()
same => n,Set(FACEBOOKID=${CALLERID(num)})
same => n,Set(ROOMID=${EXTEN})
same => n,Set(USERID=${ROOMS_USERID(${FACEBOOKID})})
same => n,Set(ALLOWED=${ROOMS_MEMBERSHIP(${FACEBOOKID},${ROOMID})})
same => n,GotoIf($[${ALLOWED} = 1]?allowed:not_allowed)
same => n(allowed),Set(ROOMS_PRESENCE(${USERID},${ROOMID})=1)
same => n,ConfBridge(${EXTEN})
same => n,Set(ROOMS_PRESENCE(${USERID},${ROOMID})=0)
same => n(not_allowed),Hangup()
and the code of my functions
[MEMBERSHIP]
dsn=MySQLRooms
prefix=ROOMS
readsql=SELECT COUNT( * ) FROM room_member
LEFT JOIN user
ON user
.id
= room_member
.user_id
WHERE user
.facebook_id
= ‘${ARG1}’ AND room_member
.room_id
= '${ARG2}'
synopsis=Test membership of a room by callerid
[USERID]
dsn=MySQLRooms
prefix=ROOMS
readsql=SELECT id
FROM user
WHERE facebook_id
= '${ARG1}'
synopsis=get the Rooms userid from the facebook_id (callerid)
[PRESENCE]
dsn=MySQLRooms
prefix=ROOMS
writesql=UPDATE room_member
SET present
=’${VAL1}’ WHERE user_id
=’${ARG1}’ AND room_id
=’${ARG2}'
synopsis=Update the presence of a user on a specific room.
The call:
same => n,Set(ROOMS_PRESENCE(${USERID},${ROOMID})=0)
is meant to be called once a user leaves ConfBridge or hangs up. But it doesn’t get called if he hangs up without exiting ConfBridge first.
Is there another way to do this? Thanks.
Martin