dart-sip-ua
dart-sip-ua copied to clipboard
Tcp socket implementation
Recently In a research project for work we were looking into integrating SIP phone functionality into our existing client flutter app. The main constraint was that it had to work with a 3cx server.
Unfortunately 3cx doesn't accept web socket connections and seeing as this was the only viable dart sip ua package on pub dev I had to go about adding the ability to connect to 3cx over tcp with this package.
I have successfully registered with a 3cx server and made calls between two clients. I then went back and made sure that I could still register fine with an Asterisk server on FreePBX using the existing websockets.
In a nutshell what i did was abstract out the websocket class into a socket_interface. Then have web_socket and tcp_socket classes extend this abstracted interface. In the example app when you register the connection, a type is chosen with a radio check box. When what ever type is chosen, the sip_ua_helper creates the appropriate socket types and adds them to the array of sockets.
The rest of the package carries on as usual not caring about what type of socket is used. It just calls .send() on the socket interface and the sockets deal with how they connect.
At the risk of sounding lame, im hoping this will eventually be accepted as it will be my first contribution as a developer to public open source code :)
Thanks @mikaelwills, this is great work. Before merging, we may need to do some checks
- Make sure this patch does not affect Flutter Web because the browser does not support TCP
- Since TCP is already supported, I think TLS can also be supported (using SecureSocket). Of course, it is not necessary. I am very interested to see if it can be supported.
Maybe I can also do some general testing and try connecting to asterisk/freeswitch/opensips using TCP/TLS
Great news.
I'll start looking into those two points. WIth the second point possibly making a third secure_socket.class the extends the abstract class and getting that to work.
This is really good news as it would make this library so much more versatile.