Note that there are some explanatory texts on larger screens.

plurals
  1. POG-WAN persist request data in handler
    primarykey
    data
    text
    <h2>Solution:</h2> <p><code>int session = (int)get_env(argv, SESSION_ID);</code> to get identifier unique to connection <code>US_VHOST_DATA</code> (vhost) or <code>US_HANDLER_DATA</code> (listener) or <code>US_SERVER_DATA</code> (server) for data persistent > current connection</p> <p>Missing pieces:</p> <ul> <li>either persistent data for connection only</li> <li>or some way to execute code when current connection is closed by client (econnreset etc.) or server (e.g. kalive_tmo reached)</li> </ul> <p>This should be solvable as soon as a new HDL_BEFORE_CLOSE state for handlers is added, which makes this question answered for me.</p> <hr> <h2>Original Question:</h2> <p>Is it possible in a G-WAN handler to store information persistent to a request/connection (don't really know if "request" applies here)? </p> <p>To better illustrate what I mean, this is what I got now:</p> <ul> <li>Client (browser, javascript) sends websocket handshake</li> <li>Handler starts, gets into: <ul> <li>HDL_AFTER_ACCEPT - here i call gc_init for US_REQUEST_DATA, and get no error</li> <li>HDL_AFTER_READ - here i check for US_REQUEST_DATA which is not yet set, so I do websocket handshake and gc_malloc + set US_REQUEST_DATA, increase KALIVE_TMO, and then return 2 to send data</li> </ul></li> <li>Client sees websocket connection as being established, so I (manually triggered some seconds afterwards) send a message</li> <li>Handler goes to HDL_AFTER_READ again, <strong>BUT US_REQUEST_DATA is not set</strong> </li> </ul> <p>What I've also tried: returning 1 instead of 2 in HDL_AFTER_READ -> client gets 404 and handshake does not work</p> <p>At the moment I'm only using US_REQUEST_DATA to identify if websocket connection is already established and next incoming data should be in websocket message format, so if there is a different (maybe better?) solution, I'm open to that as well of course.</p> <p>Thanks!</p> <p>Edit: Added clarification about request/connection</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload