Freeswitch-mod event socket

From 탱이의 잡동사니
Revision as of 08:26, 14 December 2020 by Pchero (talk | contribs) (→‎Outbound mode)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Overview

Freeswitch mod_event_socket 모듈 내용 정리

Basic

Inbound mode

Inbound mode means you run your application (in whatever languages) as client, and connect to the Freeswitch server to invoke commands and control Freeswitch.

In inbound mode, your application connects to the Freeswitch server on the given port and sends commands.

If you would like to handle incoming calls using inbound mode, you should add the uuid_park command to your dialplan. Otherwise the dialplan might complete executing before your client can send commands to the event socket.

Outbound mode

Outbound mode means you make a daemon(with whatever language), and then have Freeswitch connect to it. You add an extension to the dialplan, and put <action application="socket" data="ip:port sync full"/> and create a script that runs on that ip:port and answer, playback and everything else you need on the script. Since revision git-8c794ac, you can connect to IPv6 addresses. When using IPv6 addresses the port parameter is required:<action application="socket" data="::1:8021"/> connects to ::1 on port 8021. Since this revision hostnames resolving to IPv6 addresses can be used.

In outbound mode, also known as the "socket application"(or socket client), Freeswitch makes outbound connections to another process (similar to Asterisk's FAGI model). Using outbound connections you can have Freeswitch call your own application(s) when particular events occur.

See more detail(https://freeswitch.org/confluence/display/FREESWITCH/Event+Socket+Outbound)

Commands

api

api 명령을 전송한다(blocking mode).

api <command> <arg>

Example

api show calls

Content-Type: api/response
Content-Length: 7329

uuid,direction,created,created_epoch,name,state,cid_name,cid_num,ip_addr,dest,presence_id,presence_data,callstate,callee_name,callee_num,callee_direction,call_uuid,hostname,sent_callee_name,sent_callee_num,b_uuid,b_direction,b_created,b_created_epoch,b_name,b_state,b_cid_name,b_cid_num,b_ip_addr,b_dest,b_presence_id,b_presence_data,b_callstate,b_callee_name,b_callee_num,b_callee_direction,b_sent_callee_name,b_sent_callee_num,call_created_epoch
b5f031ca-af47-11e7-85f8-e75cb83de8fb,inbound,2017-10-12 14:20:18,1507810818,sofia/internal/asterisk@127.0.0.1,CS_EXECUTE,asterisk,asterisk,127.0.0.1,user_501,,,ACTIVE,,,,,localhost,,,,,,,,,,,,,,,,,,,,,

...
30 total

bgapi

api 명령을 back ground 로 실행한다.

Clients

telnet

telnet 으로도 접속이 가능하다. 8021 포트로 접속하며 되며, 기본 password 는 'ClueCon' 이다.

telent 접속 후, auth 명령어와 설정한 password 를 입력하면 접속이 된다.

auth <password>

Example

telnet localhost 8021
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Content-Type: auth/request

auth ClueCon

Content-Type: command/reply
Reply-Text: +OK accepted

See also