Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
5e91d919
Commit
5e91d919
authored
Nov 09, 2016
by
Sergey Lyubka
Committed by
Cesanta Bot
Nov 09, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make mg_register_http_endpoint work for websocket
PUBLISHED_FROM=5bf5a007929b3b6275121f3cf949526e881fb482
parent
59348468
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
mongoose.c
mongoose.c
+12
-0
No files found.
mongoose.c
View file @
5e91d919
...
@@ -4992,11 +4992,23 @@ void mg_http_handler(struct mg_connection *nc, int ev, void *ev_data) {
...
@@ -4992,11 +4992,23 @@ void mg_http_handler(struct mg_connection *nc, int ev, void *ev_data) {
mg_ws_handler
(
nc
,
MG_EV_RECV
,
ev_data
);
mg_ws_handler
(
nc
,
MG_EV_RECV
,
ev_data
);
}
else
if
(
nc
->
listener
!=
NULL
&&
}
else
if
(
nc
->
listener
!=
NULL
&&
(
vec
=
mg_get_http_header
(
hm
,
"Sec-WebSocket-Key"
))
!=
NULL
)
{
(
vec
=
mg_get_http_header
(
hm
,
"Sec-WebSocket-Key"
))
!=
NULL
)
{
mg_event_handler_t
handler
;
/* This is a websocket request. Switch protocol handlers. */
/* This is a websocket request. Switch protocol handlers. */
mbuf_remove
(
io
,
req_len
);
mbuf_remove
(
io
,
req_len
);
nc
->
proto_handler
=
mg_ws_handler
;
nc
->
proto_handler
=
mg_ws_handler
;
nc
->
flags
|=
MG_F_IS_WEBSOCKET
;
nc
->
flags
|=
MG_F_IS_WEBSOCKET
;
/*
* If we have a handler set up with mg_register_http_endpoint(),
* deliver subsequent websocket events to this handler after the
* protocol switch.
*/
handler
=
mg_http_get_endpoint_handler
(
nc
->
listener
,
&
hm
->
uri
);
if
(
handler
!=
NULL
)
{
nc
->
handler
=
handler
;
}
/* Send handshake */
/* Send handshake */
mg_call
(
nc
,
nc
->
handler
,
MG_EV_WEBSOCKET_HANDSHAKE_REQUEST
,
hm
);
mg_call
(
nc
,
nc
->
handler
,
MG_EV_WEBSOCKET_HANDSHAKE_REQUEST
,
hm
);
if
(
!
(
nc
->
flags
&
MG_F_CLOSE_IMMEDIATELY
))
{
if
(
!
(
nc
->
flags
&
MG_F_CLOSE_IMMEDIATELY
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment