Hello,
On 6/15/12 11:33 AM, Peter Dunkley
wrote:
Hi Daniel,
Thanks for the encouragement.
I could do with a guide here. I think there is only a few hours
work left to finish off the handshake and basic module stuff.
After that I think the next step needs to be:
- Getting the module to register with core to receive WS frames
(which may arrive over TCP or TLS)
- Giving the module/core the ability to "change" the connection
the handshake came in on from SIP/HTTP to WS (so that new messages
go straight to the handler in the new module)
- In the module adding handling for Close, Ping, and Pong
- To do the handling for Ping the module needs to be able to send
WS frames out (over TCP or TLS)
- In the module "printing" received binary and text frames (which
will contain SIP requests)
The bits I need help with here the most are the registering the
module to receive the WS frames and sending WS frames (over TCP or
TLS), and adding the ability for the module/core to "upgrade" the
connection from SIP/HTTP to WS after successful handshake.
I think of doing it like:
- when WS handshake is completed, mark the tcp connection as being
WS from the module (a new flag or so)
- then in the TCP read function (iirc, tcp_read.{c,h} in core) if
the connection is marked WS, then execute a callback that is
registered by the module
- this is pretty much how http and msrp work, but there the
detection is on the content, not on the socket type. HTTP is using
so called no-SIP content callback, while MSRP is using a dedicated
core event
For sending, using tcp_send(...) (looking at msrp module will give
the right directions) should do it -- the function takes the tcp
connection as parameter as well as the outgoing buffer and encrypts
the content if actually is over TLS. The send operation may become
transparent as soon as the algorithm for finding the connection can
grep on WS/WSS protocol.
Cheers,
Daniel
--
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio Advanced Training, Seattle, USA, Sep 23-26, 2012 - http://asipto.com/u/katu
Kamailio Practical Workshop, Netherlands, Sep 10-12, 2012 - http://asipto.com/u/kpw