Call Us Today! 877.742.2583




Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: add some code block

...

Here are examples of how to use it in the dialplan.

Code Block
<action application="socket" data="127.0.0.1:8084"/>
<action application="socket" data="127.0.0.1:8084 async"/> 
<action application="socket" data="127.0.0.1:8084 full"/>
<action application="socket" data="127.0.0.1:8084 async full"/>


Info
titleEvent Lock

If you are using async, you need to pay attention to potential race condition. The commands you send may not execute in sequential order. You may force the command to wait by setting event lock until the critical or long-running command finishes:

sendmsg 
call-command: set
execute-app-name: foo=bar\n\n
event-lock:true
 

You may obtain the same result (setting event-lock to true) in scripting using the setEventLock method of connection object:

$con->setEventLock("1");

...

Once you do this you'll be presented the name value pairs of everything related to this call including all variables.

Example:

Code Block
collapsetrue
Channel-Username: 1001
Channel-Dialplan: XML
Channel-Caller-ID-Name: 1001
Channel-Caller-ID-Number: 1001
Channel-Network-Addr: 10.0.1.241
Channel-Destination-Number: 886
Channel-Unique-ID: 40117b0a-186e-11dd-bbcd-7b74b6b4d31e
Channel-Source: mod_sofia
Channel-Context: default
Channel-Channel-Name: sofia/default/1001%4010.0.1.100
Channel-Profile-Index: 1
Channel-Channel-Created-Time: 1209749769132614
Channel-Channel-Answered-Time: 0
Channel-Channel-Hangup-Time: 0
Channel-Channel-Transfer-Time: 0
Channel-Screen-Bit: yes
Channel-Privacy-Hide-Name: no
Channel-Privacy-Hide-Number: no
Channel-State: CS_EXECUTE
Channel-State-Number: 4
Channel-Name: sofia/default/1001%4010.0.1.100
Unique-ID: 40117b0a-186e-11dd-bbcd-7b74b6b4d31e
Call-Direction: inbound
Answer-State: early
Channel-Read-Codec-Name: G722
Channel-Read-Codec-Rate: 16000
Channel-Write-Codec-Name: G722
Channel-Write-Codec-Rate: 16000
Caller-Username: 1001
Caller-Dialplan: XML
Caller-Caller-ID-Name: 1001
Caller-Caller-ID-Number: 1001
Caller-Network-Addr: 10.0.1.241
Caller-Destination-Number: 886
Caller-Unique-ID: 40117b0a-186e-11dd-bbcd-7b74b6b4d31e
Caller-Source: mod_sofia
Caller-Context: default
Caller-Channel-Name: sofia/default/1001%4010.0.1.100
Caller-Profile-Index: 1
Caller-Channel-Created-Time: 1209749769132614
Caller-Channel-Answered-Time: 0
Caller-Channel-Hangup-Time: 0
Caller-Channel-Transfer-Time: 0
Caller-Screen-Bit: yes
Caller-Privacy-Hide-Name: no
Caller-Privacy-Hide-Number: no
variable_sip_authorized: true
variable_sip_mailbox: 1001
variable_sip_auth_username: 1001
variable_sip_auth_realm: 10.0.1.100
variable_mailbox: 1001
variable_user_name: 1001
variable_domain_name: 10.0.1.100
variable_accountcode: 1001
variable_user_context: default
variable_effective_caller_id_name: Extension%201001
variable_effective_caller_id_number: 1001
variable_sip_from_user: 1001
variable_sip_from_uri: 1001%4010.0.1.100
variable_sip_from_host: 10.0.1.100
variable_sip_from_user_stripped: 1001
variable_sip_from_tag: wrgb4s5idf
variable_sofia_profile_name: default
variable_sofia_profile_domain_name: 10.0.1.100
variable_sofia_profile_domain_name: 10.0.1.100
variable_sip_req_params: user%3Dphone
variable_sip_req_user: 886
variable_sip_req_uri: 886%4010.0.1.100
variable_sip_req_host: 10.0.1.100
variable_sip_to_params: user%3Dphone
variable_sip_to_user: 886
variable_sip_to_uri: 886%4010.0.1.100
variable_sip_to_host: 10.0.1.100
variable_sip_contact_params: line%3Dnc7obl5w
variable_sip_contact_user: 1001
variable_sip_contact_port: 2048
variable_sip_contact_uri: 1001%4010.0.1.241%3A2048
variable_sip_contact_host: 10.0.1.241
variable_channel_name: sofia/default/1001%4010.0.1.100
variable_sip_call_id: 3c2bb21af10b-ogphkonpwqet
variable_sip_user_agent: snom300/7.1.30
variable_sip_via_host: 10.0.1.241
variable_sip_via_port: 2048
variable_sip_via_rport: 2048
variable_max_forwards: 70
variable_presence_id: 1001%4010.0.1.100
variable_sip_h_P-Key-Flags: keys%3D%223%22
variable_switch_r_sdp: v%3D0%0D%0Ao%3Droot%201915884124%201915884124%20IN%20IP4%2010.0.1.241%0D%0As%3Dcall%0D%0Ac%3DIN%20IP4%2010.0.1.241%0D%0At%3D0%200%0D%0Am%3Daudio%2062258%20RTP/AVP%209%202%203%2018%204%20101%0D%0Aa%3Drtpmap%3A9%20g722/8000%0D%0Aa%3Drtpmap%3A2%20g726-32/8000%0D%0Aa%3Drtpmap%3A3%20gsm/8000%0D%0Aa%3Drtpmap%3A18%20g729/8000%0D%0Aa%3Drtpmap%3A4%20g723/8000%0D%0Aa%3Drtpmap%3A101%20telephone-event/8000%0D%0Aa%3Dfmtp%3A101%200-16%0D%0Aa%3Dptime%3A20%0D%0A
variable_remote_media_ip: 10.0.1.241
variable_remote_media_port: 62258
variable_read_codec: G722
variable_read_rate: 16000
variable_write_codec: G722
variable_write_rate: 16000
variable_open: true
variable_socket_host: 127.0.0.1
variable_local_media_ip: 10.0.1.100
variable_local_media_port: 62258
variable_endpoint_disposition: EARLY%20MEDIA
Content-Type: command/reply
Socket-Mode: async
Control: full

Now lets answer this call: (Note: sendmsg doesn't need uuid arg when in outbound mode)

Code Block
sendmsg
call-command: execute
execute-app-name: answer\n\n

...


Which will reply:
Code Block
Content-Type: command/reply
Reply-Text: +OK

...


This call is now answered but its sitting there waiting on your every command.

Now lets play this call a sound file:

Code Block
sendmsg
call-command: execute
execute-app-name: playback
execute-app-arg: /tmp/swimp.raw\n\n

It is also possible to play tones:

Code Block
sendmsg
call-command: execute
execute-app-name: playback
execute-app-arg: tone_stream://%(2000,4000,440,480)\n\n

...

The reply should be:
Code Block
Content-Type: command/reply
Reply-Text: +OK

Now how do you stop the file playing? Here is how you would do that:

Code Block
sendmsg
call-command: execute
execute-app-name: break\n\n

...

The reply should be:
Code Block
Content-Type: command/reply
Reply-Text: +OK

Now lets hang this call up:

Code Block
sendmsg
call-command: execute
execute-app-name: hangup\n\n

...


The reply should be:
Code Block
Content-Type: command/reply
Reply-Text: +OK

...


Netcat will exit now.

You can also issue "myevents\n\n" or subscribe to other events in the normal way ie "events heartbeat\n\n"

...