mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-28 23:49:44 +08:00
embedding guide for MG_POLL fixed
This commit is contained in:
parent
60674c11c9
commit
6a46244a21
@ -71,16 +71,20 @@ The sequence of events for every connection is this:
|
|||||||
certain prefix, and let Mongoose serve all static files.
|
certain prefix, and let Mongoose serve all static files.
|
||||||
If event handler decides to serve the request, but doesn't have
|
If event handler decides to serve the request, but doesn't have
|
||||||
all the data at the moment, it should return `MG_MORE`. That tells
|
all the data at the moment, it should return `MG_MORE`. That tells
|
||||||
Mongoose to send `MG_POLL` events on each iteration of `mg_poll_server()`
|
Mongoose to keep the connection open after callback returns.
|
||||||
|
|
||||||
`mg_connection::connection_param` pointer is a placeholder to keep
|
`mg_connection::connection_param` pointer is a placeholder to keep
|
||||||
user-specific data. For example, handler could decide to open a DB
|
user-specific data. For example, handler could decide to open a DB
|
||||||
connection and store DB connection handle in `connection_param`.
|
connection and store DB connection handle in `connection_param`.
|
||||||
* `MG_POLL` is sent only to those connections which returned `MG_MORE`.
|
* `MG_POLL` is sent to every connection on every iteration of
|
||||||
Event handler should try to complete the reply. If reply is completed,
|
`mg_poll_server()`. Event handler should return `MG_FALSE` to ignore
|
||||||
then event handler should return `MG_TRUE`. Otherwise, it should
|
this event. If event handler returns `MG_TRUE`, then Mongoose assumes
|
||||||
return `MG_FALSE`, and polling will continue until
|
that event handler has finished sending data, and Mongoose will
|
||||||
handler returns `MG_TRUE`.
|
close the connection.
|
||||||
|
* `MG_HTTP_ERROR` sent when Mongoose is about to send HTTP error back
|
||||||
|
to the client. Event handler can choose to send a reply itself, in which
|
||||||
|
case event handler must return `MG_TRUE`. Otherwise, event handler must
|
||||||
|
return `MG_FALSE`
|
||||||
* `MG_CLOSE` is sent when the connection is closed. This event is used
|
* `MG_CLOSE` is sent when the connection is closed. This event is used
|
||||||
to cleanup per-connection state stored in `connection_param`
|
to cleanup per-connection state stored in `connection_param`
|
||||||
if it was allocated.
|
if it was allocated.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user