diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-03-12 11:23:57 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-03-12 11:23:57 +0100 |
commit | b16aeeccff8de5fd579d79a48740df7a3e34e7bc (patch) | |
tree | bb2ddcb29c6a465d73a3010437bdd076d11360c9 /misc/freeswitch/scripts/event | |
parent | 3c5a0511d228fb3dc00ae860ade1b8ff032cc42f (diff) | |
parent | 40b2feb99d75074319f371087c521df198527266 (diff) |
Merge branch 'develop' of github.com:amooma/GS5 into develop
Diffstat (limited to 'misc/freeswitch/scripts/event')
-rw-r--r-- | misc/freeswitch/scripts/event/presence_update.lua | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/misc/freeswitch/scripts/event/presence_update.lua b/misc/freeswitch/scripts/event/presence_update.lua index 01ec17b..4d0cb94 100644 --- a/misc/freeswitch/scripts/event/presence_update.lua +++ b/misc/freeswitch/scripts/event/presence_update.lua @@ -72,22 +72,31 @@ end function PresenceUpdate.presence_in(self, event) - if not event:getHeader('status') then - return - end - local account, domain = common.str.partition(event:getHeader('from'), '@'); - local direction = tostring(event:getHeader('presence-call-direction')) + local call_direction = tostring(event:getHeader('presence-call-direction') or event:getHeader('call-direction')) local state = event:getHeader('presence-call-info-state'); local uuid = event:getHeader('Unique-ID'); local caller_id = event:getHeader('Caller-Caller-ID-Number'); + local protocol = tostring(event:getHeader('proto')); + + local direction = nil; + + if call_direction == 'inbound' then + direction = true; + elseif call_direction == 'outbound' then + direction = false; + end - if direction == 'inbound' then - self.log:info('[', uuid,'] PRESENCE_INBOUND: account: ', account, ', state: ', state); - self:sip_account(true, account, domain, state, uuid); - elseif direction == 'outbound' then - self.log:info('[', uuid,'] PRESENCE_OUTBOUND: account: ', account, ', state: ', state, ', caller: ', caller_id); - self:sip_account(false, account, domain, state, uuid, caller_id); + if protocol == 'conf' then + state = event:getHeader('answer-state'); + local login = tostring(event:getHeader('proto')); + self.log:info('[', uuid,'] PRESENCE_CONFERENCE_', call_direction:upper(), ' ', common.str.to_i(account), ' - identifier: ', account, ', state: ', state); + self:conference(direction, account, domain, state, uuid); + elseif protocol == 'sip' and common.str.blank(state) then + return; + else + self.log:info('[', uuid,'] PRESENCE_', call_direction:upper(),' - protocol: ', protocol, ', account: ', account, ', state: ', state); + self:sip_account(direction, account, domain, state, uuid, caller_id); end end @@ -197,3 +206,16 @@ function PresenceUpdate.sip_account(self, inbound, account, domain, status, uuid uuid = uuid }:set(status_map[status] or 'terminated', caller_id); end + + +function PresenceUpdate.conference(self, inbound, account, domain, status, uuid) + require 'dialplan.presence' + local result = dialplan.presence.Presence:new{ + log = self.log, + database = self.database, + inbound = inbound, + domain = domain, + accounts = { account }, + uuid = uuid + }:set(status or 'terminated'); +end |