On Mon, May 4, 2015 at 5:05 PM, mayamatakeshi mayamatakeshi@gmail.com wrote:
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; }
Checking again, deletion of the entry in the hash table is failing.
In older versions of kamailio, if I am not mistaken, i used: $sht(websocket=>$conid) = null; but it seems in recent version null was replaced with $null (as if i use null, kamailio will not start) so I am using $sht(websocket=>$conid) = $null; but it seems this doesn't work. So, how do we currently delete an htable entry at config file?
Regards, Takeshi