<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    <div class="moz-cite-prefix">On 6/15/12 11:33 AM, Peter Dunkley
      wrote:<br>
    </div>
    <blockquote
      cite="mid:1339752790.4189.6.camel@pd-notebook-linux.croc.internal"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="GENERATOR" content="GtkHTML/4.4.2">
      Hi Daniel,<br>
      <br>
      Thanks for the encouragement.<br>
      <br>
      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:<br>
      - Getting the module to register with core to receive WS frames
      (which may arrive over TCP or TLS)<br>
      - 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)<br>
      - In the module adding handling for Close, Ping, and Pong<br>
      - To do the handling for Ping the module needs to be able to send
      WS frames out (over TCP or TLS)<br>
      - In the module "printing" received binary and text frames (which
      will contain SIP requests)<br>
      <br>
      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.<br>
    </blockquote>
    <br>
    I think of doing it like:<br>
    - when WS handshake is completed, mark the tcp connection as being
    WS from the module (a new flag or so)<br>
    - 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<br>
    - 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<br>
    <br>
    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.<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <br>
    <blockquote
      cite="mid:1339752790.4189.6.camel@pd-notebook-linux.croc.internal"
      type="cite">
      <table cellpadding="0" cellspacing="0" width="100%">
        <tbody>
          <tr>
            <td><br>
            </td>
          </tr>
        </tbody>
      </table>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a>
Kamailio Advanced Training, Seattle, USA, Sep 23-26, 2012 - <a class="moz-txt-link-freetext" href="http://asipto.com/u/katu">http://asipto.com/u/katu</a>
Kamailio Practical Workshop, Netherlands, Sep 10-12, 2012 - <a class="moz-txt-link-freetext" href="http://asipto.com/u/kpw">http://asipto.com/u/kpw</a></pre>
  </body>
</html>