mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-13 10:15:00 +00:00
Pass mg_http_message to MG_EV_WS_OPEN
This commit is contained in:
+14
-12
@@ -133,18 +133,20 @@ to an event handler:
|
||||
|
||||
```c
|
||||
enum {
|
||||
MG_EV_ERROR, // Error char *error_message
|
||||
MG_EV_POLL, // mg_mgr_poll iteration unsigned long *millis
|
||||
MG_EV_RESOLVE, // Host name is resolved NULL
|
||||
MG_EV_CONNECT, // Connection established NULL
|
||||
MG_EV_ACCEPT, // Connection accepted NULL
|
||||
MG_EV_READ, // Data received from socket struct mg_str *
|
||||
MG_EV_WRITE, // Data written to socket int *num_bytes_written
|
||||
MG_EV_CLOSE, // Connection closed NULL
|
||||
MG_EV_HTTP_MSG, // HTTP request/response struct mg_http_message *
|
||||
MG_EV_WS_OPEN, // Websocket handshake done NULL
|
||||
MG_EV_WS_MSG, // Websocket message received struct mg_ws_message *
|
||||
MG_EV_MQTT_MSG, // MQTT message struct mg_mqtt_message *
|
||||
MG_EV_ERROR, // Error char *error_message
|
||||
MG_EV_POLL, // mg_mgr_poll iteration unsigned long *millis
|
||||
MG_EV_RESOLVE, // Host name is resolved NULL
|
||||
MG_EV_CONNECT, // Connection established NULL
|
||||
MG_EV_ACCEPT, // Connection accepted NULL
|
||||
MG_EV_READ, // Data received from socket struct mg_str *
|
||||
MG_EV_WRITE, // Data written to socket int *num_bytes_written
|
||||
MG_EV_CLOSE, // Connection closed NULL
|
||||
MG_EV_HTTP_MSG, // HTTP request/response struct mg_http_message *
|
||||
MG_EV_WS_OPEN, // Websocket handshake done struct mg_http_message *
|
||||
MG_EV_WS_MSG, // Websocket msg, text or bin struct mg_ws_message *
|
||||
MG_EV_WS_CTL, // Websocket control msg struct mg_ws_message *
|
||||
MG_EV_MQTT_CMD, // MQTT low-level command struct mg_mqtt_message *
|
||||
MG_EV_MQTT_MSG, // MQTT PUBLISH received struct mg_mqtt_message *
|
||||
MG_EV_MQTT_OPEN, // MQTT CONNACK received int *connack_status_code
|
||||
MG_EV_SNTP_TIME, // SNTP time received struct timeval *
|
||||
MG_EV_USER, // Starting ID for user events
|
||||
|
||||
+3
-1
@@ -4071,8 +4071,10 @@ static void mg_ws_cb(struct mg_connection *c, int ev, void *ev_data,
|
||||
("%lu WS handshake error: %.*s", c->id, 15, c->recv.buf));
|
||||
c->is_closing = 1;
|
||||
} else {
|
||||
struct mg_http_message hm;
|
||||
mg_http_parse((char *) c->recv.buf, c->recv.len, &hm);
|
||||
c->is_websocket = 1;
|
||||
mg_call(c, MG_EV_WS_OPEN, NULL);
|
||||
mg_call(c, MG_EV_WS_OPEN, &hm);
|
||||
}
|
||||
mg_iobuf_delete(&c->recv, n);
|
||||
} else {
|
||||
|
||||
+3
-3
@@ -564,9 +564,9 @@ enum {
|
||||
MG_EV_WRITE, // Data written to socket int *num_bytes_written
|
||||
MG_EV_CLOSE, // Connection closed NULL
|
||||
MG_EV_HTTP_MSG, // HTTP request/response struct mg_http_message *
|
||||
MG_EV_WS_OPEN, // Websocket handshake done NULL
|
||||
MG_EV_WS_MSG, // Websocket message received struct mg_ws_message *
|
||||
MG_EV_WS_CTL, // Websocket control message struct mg_ws_message *
|
||||
MG_EV_WS_OPEN, // Websocket handshake done struct mg_http_message *
|
||||
MG_EV_WS_MSG, // Websocket msg, text or bin struct mg_ws_message *
|
||||
MG_EV_WS_CTL, // Websocket control msg struct mg_ws_message *
|
||||
MG_EV_MQTT_CMD, // MQTT low-level command struct mg_mqtt_message *
|
||||
MG_EV_MQTT_MSG, // MQTT PUBLISH received struct mg_mqtt_message *
|
||||
MG_EV_MQTT_OPEN, // MQTT CONNACK received int *connack_status_code
|
||||
|
||||
+3
-3
@@ -27,9 +27,9 @@ enum {
|
||||
MG_EV_WRITE, // Data written to socket int *num_bytes_written
|
||||
MG_EV_CLOSE, // Connection closed NULL
|
||||
MG_EV_HTTP_MSG, // HTTP request/response struct mg_http_message *
|
||||
MG_EV_WS_OPEN, // Websocket handshake done NULL
|
||||
MG_EV_WS_MSG, // Websocket message received struct mg_ws_message *
|
||||
MG_EV_WS_CTL, // Websocket control message struct mg_ws_message *
|
||||
MG_EV_WS_OPEN, // Websocket handshake done struct mg_http_message *
|
||||
MG_EV_WS_MSG, // Websocket msg, text or bin struct mg_ws_message *
|
||||
MG_EV_WS_CTL, // Websocket control msg struct mg_ws_message *
|
||||
MG_EV_MQTT_CMD, // MQTT low-level command struct mg_mqtt_message *
|
||||
MG_EV_MQTT_MSG, // MQTT PUBLISH received struct mg_mqtt_message *
|
||||
MG_EV_MQTT_OPEN, // MQTT CONNACK received int *connack_status_code
|
||||
|
||||
@@ -119,8 +119,10 @@ static void mg_ws_cb(struct mg_connection *c, int ev, void *ev_data,
|
||||
("%lu WS handshake error: %.*s", c->id, 15, c->recv.buf));
|
||||
c->is_closing = 1;
|
||||
} else {
|
||||
struct mg_http_message hm;
|
||||
mg_http_parse((char *) c->recv.buf, c->recv.len, &hm);
|
||||
c->is_websocket = 1;
|
||||
mg_call(c, MG_EV_WS_OPEN, NULL);
|
||||
mg_call(c, MG_EV_WS_OPEN, &hm);
|
||||
}
|
||||
mg_iobuf_delete(&c->recv, n);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user