[SR-Users] WebSocket data in TCP connection

mayamatakeshi mayamatakeshi at gmail.com
Mon May 4 10:05:53 CEST 2015


On Sun, May 3, 2015 at 7:21 PM, mayamatakeshi <mayamatakeshi at gmail.com>
wrote:

> Hello,
>
> about module websocket, is it possible to associate a value with the TCP
> connection and have this value readable when handling SIP requests on that
> connection?
>

Hello, I have found a way to do it using htable.
Here is the gist of it in case someone else needs this:


loadmodule "xhttp.so"
loadmodule "websocket.so"

modparam("htable", "htable", "websocket=>size=10")

route {
    if(proto == WS) {
        xlog("L_DEBUG", "WebSocket check: conid=$conid
val=$sht(websocket=>$conid)\n");
    }
}

event_route[xhttp:request] {
    if (ws_handle_handshake()) {
        # successful connection
#adding $conid to hash table
        $sht(websocket=>$conid) = $hu;
        exit;
     }
}

event_route[websocket:closed] {
    xlog("L_DEBUG", "WebSocket connection from $si:$sp has closed\n");
    # deleting $conid from hash table
    $sht(websocket=>$conid) = $null;
}


Regards,
Takeshi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20150504/dd6cb1dd/attachment.html>


More information about the sr-users mailing list