FreeSWITCH™ is an opensource PBX that has been changed my world. This is the first post of a series of posts that I will make on the subject. FsGUI, one of my creations is a good starting point towards the «why» I have chosen FreeSWITCH™.
It makes no sense to use just about any system nowadays that is not able to integrate with 3rd party systems easily. Telephony systems are not an exception. Proof of that would be the existence of all the open and closed standards available such as CSTA/TAPI/TSAPI and others. FreeSWITCH™ is not an exception to the rule either and in fact it goes an extra mile. On this article we will explain how FreeSWITCH™ implements this «CTI/CCI port» and provide one interesting use case called FSGui.
FreeSWITCH™ has a very efficient internal event subsystem at the disposal of its components for just about any use ranging from simple informational to the very core state machine of its channels. Modules are able to bind (or subscribe if you like) to events and receive a callback whenever those events are fired anywhere else on the code. One module we are specifically interested in is mod_event_socket.
This module binds to all events broadcasted by the core and consumes these events serializing them and sending it to a socket. For those intimate to Asterisk will immediately think of AMI but the concept is not quite the same despite the fact that some applications could be ported to FreeSWITCH™ using the same «concepts».
The first big difference would be that AMI implies that a client is connecting to Asterisk and listening in those events and Asterisk cannot ever initiate the connection. Much like AMI, Event Socket exposes the channel handling applications as well as their events when you are using this connection method which we will call inbound. But Event Socket does not stop there. It is also able to initiate a connection at the users request. This method we call outbound socket and the greatest benefit is that you could literally bypass the dialplan and hand control of the channel completely to an external application that could be running anywhere on a TCP capable network.
The other big difference is that the FreeSWITCH™ group decided that the protocol specification was not enough. What is the point of having yet another protocol for integration if everyone that wants to integrate with the system needs to implement that specification? Because the answer is pretty obvious, the group decided to also maintain a client library that understands the protocol and creates an abstraction for whoever is trying to make new applications and/or integrate with the system. This client library is called Event Socket Library (ESL).
ESL is written in C and runs on Linux, Windows, Solaris and MacOSX. You must be thinking: «So I need to write an application in C to be able to take advantage of ESL?». Not everyone knows C and the world is dominated by the high level programming languages, so that wouldn’t have been a good decision either. Instead, the FreeSWITCH™ group created a C++ wrapper to the library and used SWIG on it to create support for several well known high level programming languages. The list is long, but think on the lines of Python, PHP, Perl, Java and Ruby. A bit more interesting than AMI, don’t you think?
The other great thing that ESL provides is that ability to bind to log messages as well. As a matter of fact, the analog to «asterisk -r», fs_cli is written using ESL and for it to work, you need mod_event_socket loaded on the system. This feature is what we use to implement FSGui. But what is FSGui?
FSGui is and application that is written in C++, using Qt and ESL, to create a console much like fs_cli but without a terminal. This means that we are able to connect to a FreeSWITCH™ server (or several, using the server tabs), receive the logging events and execute several search operations. Since ESL provides the channel UUID (when available) and not only the log message/level, we are also able to filter messages realtime per channel UUID. It is pretty much like looking at a busy server but then deciding that we want to look at log messages that belong uniquely to the call of interest.
FSGui currently runs on MacOSX (Intel only), Windows and Linux. The official webpage for it is here.0