Trying to use the event socket to see extensions status

Status
Not open for further replies.

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,044
565
113
I'm trying to use the event socket to determine whether and extension is engaged.

Has anyone already skinned this cat?

I don't really want to query I want to take an event and stick it somewhere. At the moment the best bet seems to take any PRESENCE_IN event and then update using that.

If we were dealing with purely non-call waiting situation then I could just set the extension to available status when we have received a state 'terminated' from the event. With call waiting this is no good as we need to know whether there are multiple calls. I think there may always be a 'ringing' state so I could use that to increment an extensions call count but its possible we may receive multiple ringing events for a single call without a terminated in between.

Any help is welcome :)
 

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,044
565
113
Actually, it looks like the RINGING, that I was looking at is not a reliable state, I was using Channel-Call-State but that shows ringing even though it appeasrs now answered. It looks like Answer-State or status would be more reliable.:

Code:
{   u'Answer-State': u'ringing',
    u'Call-Direction': u'inbound',
    u'Caller-ANI': u'200',
    u'Caller-Caller-ID-Name': u'200',
    u'Caller-Caller-ID-Number': u'200',
    u'Caller-Channel-Answered-Time': u'0',
    u'Caller-Channel-Bridged-Time': u'0',
    u'Caller-Channel-Created-Time': u'1607342208042198',
    u'Caller-Channel-Hangup-Time': u'0',
    u'Caller-Channel-Hold-Accum': u'0',
    u'Caller-Channel-Last-Hold': u'0',
    u'Caller-Channel-Name': u'sofia/internal/200@lstest.mypbxdomain.com',
    u'Caller-Channel-Progress-Media-Time': u'0',
    u'Caller-Channel-Progress-Time': u'0',
    u'Caller-Channel-Resurrect-Time': u'0',
    u'Caller-Channel-Transfer-Time': u'0',
    u'Caller-Context': u'lstest.mypbxdomain.com',
    u'Caller-Destination-Number': u'*9664',
    u'Caller-Dialplan': u'XML',
    u'Caller-Direction': u'inbound',
    u'Caller-Logical-Direction': u'inbound',
    u'Caller-Network-Addr': u'86.1.232.35',
    u'Caller-Orig-Caller-ID-Name': u'200',
    u'Caller-Orig-Caller-ID-Number': u'200',
    u'Caller-Privacy-Hide-Name': u'false',
    u'Caller-Privacy-Hide-Number': u'false',
    u'Caller-Profile-Created-Time': u'1607342208042198',
    u'Caller-Profile-Index': u'1',
    u'Caller-Screen-Bit': u'true',
    u'Caller-Source': u'mod_sofia',
    u'Caller-Unique-ID': u'aad686ac-13e9-432e-9beb-f5a7ad6ac1f3',
    u'Caller-Username': u'200',
    u'Channel-Call-State': u'RINGING',
    u'Channel-Call-UUID': u'aad686ac-13e9-432e-9beb-f5a7ad6ac1f3',
    u'Channel-HIT-Dialplan': u'true',
    u'Channel-Name': u'sofia/internal/200@lstest.mypbxdomain.com',
    u'Channel-Presence-ID': u'200@lstest.mypbxdomain.com',
    u'Channel-Read-Codec-Bit-Rate': u'64000',
    u'Channel-Read-Codec-Name': u'G722',
    u'Channel-Read-Codec-Rate': u'16000',
    u'Channel-State': u'CS_ROUTING',
    u'Channel-State-Number': u'4',
    u'Channel-Write-Codec-Bit-Rate': u'64000',
    u'Channel-Write-Codec-Name': u'G722',
    u'Channel-Write-Codec-Rate': u'16000',
    u'Core-UUID': u'0800441e-aa88-477e-885c-f0e10180bb34',
    u'Event-Calling-File': u'switch_channel.c',
    u'Event-Calling-Function': u'switch_channel_perform_presence',
    u'Event-Calling-Line-Number': u'799',
    u'Event-Date-GMT': u'Mon, 07 Dec 2020 11:56:48 GMT',
    u'Event-Date-Local': u'2020-12-07 11:56:48',
    u'Event-Date-Timestamp': u'1607342208082199',
    u'Event-Name': u'PRESENCE_IN',
    u'Event-Sequence': u'3439218',
    u'FreeSWITCH-Hostname': u'ls1',
    u'FreeSWITCH-IPv4': u'172.26.0.85',
    u'FreeSWITCH-IPv6': u'::1',
    u'FreeSWITCH-Switchname': u'ls1',
    u'Presence-Call-Direction': u'inbound',
    u'Presence-Calling-File': u'src/switch_core_state_machine.c',
    u'Presence-Calling-Function': u'check_presence',
    u'Presence-Calling-Line': u'525',
    u'Unique-ID': u'aad686ac-13e9-432e-9beb-f5a7ad6ac1f3',
    u'alt_event_type': u'dialog',
    u'event_count': u'0',
    u'event_type': u'presence',
    u'from': u'200@lstest.mypbxdomain.com',
    u'login': u'src/switch_channel.c',
    u'presence-call-direction': u'inbound',
    u'presence-call-info-state': u'alerting',
    u'proto': u'any',
    u'rpid': u'unknown',
    u'status': u'CS_ROUTING'}
200@lstest.mypbxdomain.com RINGING
{   u'Answer-State': u'answered',
    u'Call-Direction': u'inbound',
    u'Caller-ANI': u'200',
    u'Caller-Caller-ID-Name': u'200',
    u'Caller-Caller-ID-Number': u'200',
    u'Caller-Channel-Answered-Time': u'1607342208082199',
    u'Caller-Channel-Bridged-Time': u'0',
    u'Caller-Channel-Created-Time': u'1607342208042198',
    u'Caller-Channel-Hangup-Time': u'0',
    u'Caller-Channel-Hold-Accum': u'0',
    u'Caller-Channel-Last-Hold': u'0',
    u'Caller-Channel-Name': u'sofia/internal/200@lstest.mypbxdomain.com',
    u'Caller-Channel-Progress-Media-Time': u'0',
    u'Caller-Channel-Progress-Time': u'0',
    u'Caller-Channel-Resurrect-Time': u'0',
    u'Caller-Channel-Transfer-Time': u'0',
    u'Caller-Context': u'lstest.mypbxdomain.com',
    u'Caller-Destination-Number': u'*9664',
    u'Caller-Dialplan': u'XML',
    u'Caller-Direction': u'inbound',
    u'Caller-Logical-Direction': u'inbound',
    u'Caller-Network-Addr': u'86.1.232.35',
    u'Caller-Orig-Caller-ID-Name': u'200',
    u'Caller-Orig-Caller-ID-Number': u'200',
    u'Caller-Privacy-Hide-Name': u'false',
    u'Caller-Privacy-Hide-Number': u'false',
    u'Caller-Profile-Created-Time': u'1607342208042198',
    u'Caller-Profile-Index': u'1',
    u'Caller-Screen-Bit': u'true',
    u'Caller-Source': u'mod_sofia',
    u'Caller-Unique-ID': u'aad686ac-13e9-432e-9beb-f5a7ad6ac1f3',
    u'Caller-Username': u'200',
    u'Channel-Call-State': u'RINGING',
    u'Channel-Call-UUID': u'aad686ac-13e9-432e-9beb-f5a7ad6ac1f3',
    u'Channel-HIT-Dialplan': u'true',
    u'Channel-Name': u'sofia/internal/200@lstest.mypbxdomain.com',
    u'Channel-Presence-ID': u'200@lstest.mypbxdomain.com',
    u'Channel-Read-Codec-Bit-Rate': u'64000',
    u'Channel-Read-Codec-Name': u'G722',
    u'Channel-Read-Codec-Rate': u'16000',
    u'Channel-State': u'CS_EXECUTE',
    u'Channel-State-Number': u'4',
    u'Channel-Write-Codec-Bit-Rate': u'64000',
    u'Channel-Write-Codec-Name': u'G722',
    u'Channel-Write-Codec-Rate': u'16000',
    u'Core-UUID': u'0800441e-aa88-477e-885c-f0e10180bb34',
    u'Event-Calling-File': u'switch_channel.c',
    u'Event-Calling-Function': u'switch_channel_perform_presence',
    u'Event-Calling-Line-Number': u'799',
    u'Event-Date-GMT': u'Mon, 07 Dec 2020 11:56:48 GMT',
    u'Event-Date-Local': u'2020-12-07 11:56:48',
    u'Event-Date-Timestamp': u'1607342208082199',
    u'Event-Name': u'PRESENCE_IN',
    u'Event-Sequence': u'3439235',
    u'FreeSWITCH-Hostname': u'ls1',
    u'FreeSWITCH-IPv4': u'172.26.0.85',
    u'FreeSWITCH-IPv6': u'::1',
    u'FreeSWITCH-Switchname': u'ls1',
    u'Presence-Call-Direction': u'inbound',
    u'Presence-Calling-File': u'src/switch_channel.c',
    u'Presence-Calling-Function': u'switch_channel_perform_mark_answered',
    u'Presence-Calling-Line': u'3859',
    u'Unique-ID': u'aad686ac-13e9-432e-9beb-f5a7ad6ac1f3',
    u'alt_event_type': u'dialog',
    u'event_count': u'1',
    u'event_type': u'presence',
    u'from': u'200@lstest.mypbxdomain.com',
    u'login': u'src/switch_channel.c',
    u'presence-call-direction': u'inbound',
    u'presence-call-info-state': u'active',
    u'proto': u'any',
    u'rpid': u'unknown',
    u'status': u'answered'}
200@lstest.mypbxdomain.com RINGING
{   u'Answer-State': u'hangup',
    u'Call-Direction': u'inbound',
    u'Caller-ANI': u'200',
    u'Caller-Caller-ID-Name': u'200',
    u'Caller-Caller-ID-Number': u'200',
    u'Caller-Channel-Answered-Time': u'1607342208082199',
    u'Caller-Channel-Bridged-Time': u'0',
    u'Caller-Channel-Created-Time': u'1607342208042198',
    u'Caller-Channel-Hangup-Time': u'1607342213622209',
    u'Caller-Channel-Hold-Accum': u'0',
    u'Caller-Channel-Last-Hold': u'0',
    u'Caller-Channel-Name': u'sofia/internal/200@lstest.mypbxdomain.com',
    u'Caller-Channel-Progress-Media-Time': u'0',
    u'Caller-Channel-Progress-Time': u'0',
    u'Caller-Channel-Resurrect-Time': u'0',
    u'Caller-Channel-Transfer-Time': u'0',
    u'Caller-Context': u'lstest.mypbxdomain.com',
    u'Caller-Destination-Number': u'*9664',
    u'Caller-Dialplan': u'XML',
    u'Caller-Direction': u'inbound',
    u'Caller-Logical-Direction': u'inbound',
    u'Caller-Network-Addr': u'86.1.232.35',
    u'Caller-Orig-Caller-ID-Name': u'200',
    u'Caller-Orig-Caller-ID-Number': u'200',
    u'Caller-Privacy-Hide-Name': u'false',
    u'Caller-Privacy-Hide-Number': u'false',
    u'Caller-Profile-Created-Time': u'1607342208042198',
    u'Caller-Profile-Index': u'1',
    u'Caller-Screen-Bit': u'true',
    u'Caller-Source': u'mod_sofia',
    u'Caller-Unique-ID': u'aad686ac-13e9-432e-9beb-f5a7ad6ac1f3',
    u'Caller-Username': u'200',
    u'Channel-Call-State': u'HANGUP',
    u'Channel-Call-UUID': u'aad686ac-13e9-432e-9beb-f5a7ad6ac1f3',
    u'Channel-HIT-Dialplan': u'true',
    u'Channel-Name': u'sofia/internal/200@lstest.mypbxdomain.com',
    u'Channel-Presence-ID': u'200@lstest.mypbxdomain.com',
    u'Channel-Read-Codec-Bit-Rate': u'64000',
    u'Channel-Read-Codec-Name': u'G722',
    u'Channel-Read-Codec-Rate': u'16000',
    u'Channel-State': u'CS_HANGUP',
    u'Channel-State-Number': u'11',
    u'Channel-Write-Codec-Bit-Rate': u'64000',
    u'Channel-Write-Codec-Name': u'G722',
    u'Channel-Write-Codec-Rate': u'16000',
    u'Core-UUID': u'0800441e-aa88-477e-885c-f0e10180bb34',
    u'Event-Calling-File': u'switch_channel.c',
    u'Event-Calling-Function': u'switch_channel_perform_presence',
    u'Event-Calling-Line-Number': u'799',
    u'Event-Date-GMT': u'Mon, 07 Dec 2020 11:56:53 GMT',
    u'Event-Date-Local': u'2020-12-07 11:56:53',
    u'Event-Date-Timestamp': u'1607342213622209',
    u'Event-Name': u'PRESENCE_IN',
    u'Event-Sequence': u'3439286',
    u'FreeSWITCH-Hostname': u'ls1',
    u'FreeSWITCH-IPv4': u'172.26.0.85',
    u'FreeSWITCH-IPv6': u'::1',
    u'FreeSWITCH-Switchname': u'ls1',
    u'Hangup-Cause': u'NORMAL_CLEARING',
    u'Presence-Call-Direction': u'inbound',
    u'Presence-Calling-File': u'src/switch_core_state_machine.c',
    u'Presence-Calling-Function': u'check_presence',
    u'Presence-Calling-Line': u'525',
    u'Unique-ID': u'aad686ac-13e9-432e-9beb-f5a7ad6ac1f3',
    u'alt_event_type': u'dialog',
    u'event_count': u'2',
    u'event_type': u'presence',
    u'from': u'200@lstest.mypbxdomain.com',
    u'login': u'src/switch_channel.c',
    u'presence-call-direction': u'inbound',
    u'presence-call-info-state': u'idle',
    u'proto': u'any',
    u'rpid': u'unknown',
    u'status': u'CS_HANGUP'}
 

ubergoober

New Member
Mar 10, 2018
18
2
3
60
I'm subscribing to CHANNEL_HANGUP_COMPLETE and CHANNEL_ANSWER events to get that information, but I'm not dealing with call waiting in my small environment.
 
Status
Not open for further replies.