Reading and sending events via telnet

The following example shows how to connect to mod_event_socket via telnet, and start viewing all events, as they come into the Event System bus. In bold is what we typed. After each command, press "Enter" twice:

telnet 127.0.0.1 8021 
Trying 127.0.0.1... 
Connected to 127.0.0.1. 
Escape character is '^]'. 
Content-Type: auth/request 
 
auth ClueCon 
 
Content-Type: command/reply 
Reply-Text: +OK accepted 
 
events plain all 
 
Content-Type: command/reply 
Reply-Text: +OK event listener enabled plain 

From now on, we'll see the events zapping through our terminal. On an idle FreeSWITCH server, we'll see mainly HEARTBEAT and RE_SCHEDULE events. On a busy system, we'll not be able to discern in the fast flow. Remember, to escape from the telnet connection type "Ctrl-]", and then "quit" to close it.

Obviously, it becomes much more interesting if we watch it during a call (use a terminal with a very big scrollback buffer, or use the "screen" utility, so you can seek up and down the events):

Later, and in examples, we'll see how to send commands, inject events, and only see the event types we're interested in.

Let's see a quick example on how to send an event into the Event System bus. We first use the command "sendevent" with a message type, and then we add the headers needed by that event type (default headers are automatically added by FreeSWITCH), and last we type the body, followed by a double carriage return. In bold what we type, after telnetting to localhost port 8021 (hit "Enter" twice after "ClueCon" and after "World"):

auth ClueCon 
 
Content-Type: command/reply 
Reply-Text: +OK accepted 
 
sendevent SEND_MESSAGE 
Content-Type: text/plain 
User: 1001 
Profile: internal 
Host: lab.opentelecomsolutions.com 
Content-Lenght: 11 
Hello World 
 
Content-Type: command/reply 
Reply-Text: +OK df178dbd-9b9a-4b48-bcc0-440737e4a2f6 

This event, of type MESSAGE, will send a SIP SIMPLE chat message to phones registered as "1001" user on our "lab.opentelecomsolutions.com" domain. Linphone and almost all other SIP softphones can display SIP chat messages.
Remember, to exit your established telnet session, use the "Ctrl-]" key sequence, followed by "quit".

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.48.60