mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-14 19:03:20 +00:00
Fix #1334 - typo in mg_call(..MG_EV_WS_OPEN) call
This commit is contained in:
1 parent
b739aa89f1
commit
8b770d2a0d
3 files changed
+12
-10
No files matched your search
+5
-5
@@ -4514,7 +4514,7 @@ static size_t ws_process(uint8_t *buf, size_t len, struct ws_msg *msg) {
|
|||||||
} else if (len >= 10 + mask_len) {
|
} else if (len >= 10 + mask_len) {
|
||||||
msg->header_len = 10 + mask_len;
|
msg->header_len = 10 + mask_len;
|
||||||
msg->data_len =
|
msg->data_len =
|
||||||
(size_t)(((uint64_t) mg_ntohl(*(uint32_t *) &buf[2])) << 32) +
|
(size_t) (((uint64_t) mg_ntohl(*(uint32_t *) &buf[2])) << 32) +
|
||||||
mg_ntohl(*(uint32_t *) &buf[6]);
|
mg_ntohl(*(uint32_t *) &buf[6]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4528,7 +4528,7 @@ static size_t ws_process(uint8_t *buf, size_t len, struct ws_msg *msg) {
|
|||||||
|
|
||||||
static size_t mkhdr(size_t len, int op, bool is_client, uint8_t *buf) {
|
static size_t mkhdr(size_t len, int op, bool is_client, uint8_t *buf) {
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
buf[0] = (uint8_t)(op | WEBSOCKET_FLAGS_MASK_FIN);
|
buf[0] = (uint8_t) (op | WEBSOCKET_FLAGS_MASK_FIN);
|
||||||
if (len < 126) {
|
if (len < 126) {
|
||||||
buf[1] = (unsigned char) len;
|
buf[1] = (unsigned char) len;
|
||||||
n = 2;
|
n = 2;
|
||||||
@@ -4540,9 +4540,9 @@ static size_t mkhdr(size_t len, int op, bool is_client, uint8_t *buf) {
|
|||||||
} else {
|
} else {
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
buf[1] = 127;
|
buf[1] = 127;
|
||||||
tmp = mg_htonl((uint32_t)((uint64_t) len >> 32));
|
tmp = mg_htonl((uint32_t) ((uint64_t) len >> 32));
|
||||||
memcpy(&buf[2], &tmp, sizeof(tmp));
|
memcpy(&buf[2], &tmp, sizeof(tmp));
|
||||||
tmp = mg_htonl((uint32_t)(len & 0xffffffff));
|
tmp = mg_htonl((uint32_t) (len & 0xffffffff));
|
||||||
memcpy(&buf[6], &tmp, sizeof(tmp));
|
memcpy(&buf[6], &tmp, sizeof(tmp));
|
||||||
n = 10;
|
n = 10;
|
||||||
}
|
}
|
||||||
@@ -4687,7 +4687,7 @@ void mg_ws_upgrade(struct mg_connection *c, struct mg_http_message *hm,
|
|||||||
ws_handshake(c, wskey, wsproto, fmt, ap);
|
ws_handshake(c, wskey, wsproto, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
c->is_websocket = 1;
|
c->is_websocket = 1;
|
||||||
mg_call(c, MG_EV_WS_OPEN, &hm);
|
mg_call(c, MG_EV_WS_OPEN, hm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ static size_t ws_process(uint8_t *buf, size_t len, struct ws_msg *msg) {
|
|||||||
} else if (len >= 10 + mask_len) {
|
} else if (len >= 10 + mask_len) {
|
||||||
msg->header_len = 10 + mask_len;
|
msg->header_len = 10 + mask_len;
|
||||||
msg->data_len =
|
msg->data_len =
|
||||||
(size_t)(((uint64_t) mg_ntohl(*(uint32_t *) &buf[2])) << 32) +
|
(size_t) (((uint64_t) mg_ntohl(*(uint32_t *) &buf[2])) << 32) +
|
||||||
mg_ntohl(*(uint32_t *) &buf[6]);
|
mg_ntohl(*(uint32_t *) &buf[6]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ static size_t ws_process(uint8_t *buf, size_t len, struct ws_msg *msg) {
|
|||||||
|
|
||||||
static size_t mkhdr(size_t len, int op, bool is_client, uint8_t *buf) {
|
static size_t mkhdr(size_t len, int op, bool is_client, uint8_t *buf) {
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
buf[0] = (uint8_t)(op | WEBSOCKET_FLAGS_MASK_FIN);
|
buf[0] = (uint8_t) (op | WEBSOCKET_FLAGS_MASK_FIN);
|
||||||
if (len < 126) {
|
if (len < 126) {
|
||||||
buf[1] = (unsigned char) len;
|
buf[1] = (unsigned char) len;
|
||||||
n = 2;
|
n = 2;
|
||||||
@@ -86,9 +86,9 @@ static size_t mkhdr(size_t len, int op, bool is_client, uint8_t *buf) {
|
|||||||
} else {
|
} else {
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
buf[1] = 127;
|
buf[1] = 127;
|
||||||
tmp = mg_htonl((uint32_t)((uint64_t) len >> 32));
|
tmp = mg_htonl((uint32_t) ((uint64_t) len >> 32));
|
||||||
memcpy(&buf[2], &tmp, sizeof(tmp));
|
memcpy(&buf[2], &tmp, sizeof(tmp));
|
||||||
tmp = mg_htonl((uint32_t)(len & 0xffffffff));
|
tmp = mg_htonl((uint32_t) (len & 0xffffffff));
|
||||||
memcpy(&buf[6], &tmp, sizeof(tmp));
|
memcpy(&buf[6], &tmp, sizeof(tmp));
|
||||||
n = 10;
|
n = 10;
|
||||||
}
|
}
|
||||||
@@ -233,7 +233,7 @@ void mg_ws_upgrade(struct mg_connection *c, struct mg_http_message *hm,
|
|||||||
ws_handshake(c, wskey, wsproto, fmt, ap);
|
ws_handshake(c, wskey, wsproto, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
c->is_websocket = 1;
|
c->is_websocket = 1;
|
||||||
mg_call(c, MG_EV_WS_OPEN, &hm);
|
mg_call(c, MG_EV_WS_OPEN, hm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -378,6 +378,8 @@ static void eh1(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
|||||||
mg_http_serve_dir(c, hm, &sopts);
|
mg_http_serve_dir(c, hm, &sopts);
|
||||||
}
|
}
|
||||||
} else if (ev == MG_EV_WS_OPEN) {
|
} else if (ev == MG_EV_WS_OPEN) {
|
||||||
|
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||||
|
ASSERT(mg_strcmp(hm->uri, mg_str("/ws")) == 0);
|
||||||
mg_ws_send(c, "opened", 6, WEBSOCKET_OP_BINARY);
|
mg_ws_send(c, "opened", 6, WEBSOCKET_OP_BINARY);
|
||||||
} else if (ev == MG_EV_WS_MSG) {
|
} else if (ev == MG_EV_WS_MSG) {
|
||||||
struct mg_ws_message *wm = (struct mg_ws_message *) ev_data;
|
struct mg_ws_message *wm = (struct mg_ws_message *) ev_data;
|
||||||
|
|||||||
Reference in new issue
Block a user