use struct mg_connection::connection_param pointer.
It is a placeholder for per-connection user data.

MG_REQUEST is sent once, then if handler returns MG_MORE, MG_POLLs are sent.
So for each connection, a sequence of events is:

MG_AUTH -> MG_REQUEST (handler returns MG_TRUE) -> MG_CLOSE
MG_AUTH -> MG_REQUEST (handler returns MG_MORE) -> MG_POLL ..... -> MG_CLOSE

Hope that helps.




On Fri, Sep 5, 2014 at 10:33 AM, Puneet Bakshi <[email protected]>
wrote:

>
>
> Hi,
>
> I have two queries​
>
>
> [1]
> ev_handler(conn, ev)
> {
>     if (ev == MG_REQUEST) {
>        result = req_hdlr()
>     } else if (ev == MG_AUTH) {
>        result = auth_hdlr()
>     } if (ev == MG_POLL) {
>        result = poll_hdlr()
>     }
>
>      return result;
> }
>
> How can I check whether the connection is a new connection or the same
> connection is calling ev_handler() multiple times (may be because we
> returned MG_MORE in last call)?
>
>
> [2]
> I am working with async request calls. I can have multiple such concurrent
> requests. How can I embed my context in mongoose "conn", so that I can
> recognize (in poll_hdlr()) which of my request is completed?
>
> ev_handler(conn, ev)
> {
>     void *my_ctx = ...;
>
>     if (ev == MG_REQUEST) {
>        result = req_hdlr()
>
>     } else if (ev == MG_AUTH) {
>        result = auth_hdlr()
>
>     } if (ev == MG_POLL) {
>
>        if (new connection) {
>            embed my_ctx in conn;
>        } else if ((old connection) && (work is done)) {
>             retrieve my_ctx from conn and work on it;
>             return MG_TRUE;
>        }
>
>        result = poll_hdlr()
>     }
> }
>
> Regards,
> ~Puneet
>
> --
> You received this message because you are subscribed to the Google Groups
> "mongoose-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/mongoose-users.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to