On Sun, May 3, 2015 at 7:21 PM, mayamatakeshi mayamatakeshi@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