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
1a64d37f
Commit
1a64d37f
authored
Sep 29, 2013
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed mg_websocket_read()
parent
9cca843a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
8 deletions
+3
-8
websocket.c
examples/websocket.c
+2
-0
mongoose.c
mongoose.c
+1
-8
No files found.
examples/websocket.c
View file @
1a64d37f
...
@@ -28,9 +28,11 @@ static int event_handler(struct mg_event *event) {
...
@@ -28,9 +28,11 @@ static int event_handler(struct mg_event *event) {
while
((
len
=
mg_websocket_read
(
event
->
conn
,
&
bits
,
&
data
))
>
0
)
{
while
((
len
=
mg_websocket_read
(
event
->
conn
,
&
bits
,
&
data
))
>
0
)
{
// Echo message back to the client
// Echo message back to the client
mg_websocket_write
(
event
->
conn
,
WEBSOCKET_OPCODE_TEXT
,
data
,
len
);
mg_websocket_write
(
event
->
conn
,
WEBSOCKET_OPCODE_TEXT
,
data
,
len
);
printf
(
"got message: [%.*s]
\n
"
,
len
,
data
);
if
(
memcmp
(
data
,
"exit"
,
4
)
==
0
)
{
if
(
memcmp
(
data
,
"exit"
,
4
)
==
0
)
{
mg_websocket_write
(
event
->
conn
,
mg_websocket_write
(
event
->
conn
,
WEBSOCKET_OPCODE_CONNECTION_CLOSE
,
""
,
0
);
WEBSOCKET_OPCODE_CONNECTION_CLOSE
,
""
,
0
);
free
(
data
);
break
;
break
;
}
}
}
}
...
...
mongoose.c
View file @
1a64d37f
...
@@ -4090,14 +4090,7 @@ int mg_websocket_read(struct mg_connection *conn, int *bits, char **data) {
...
@@ -4090,14 +4090,7 @@ int mg_websocket_read(struct mg_connection *conn, int *bits, char **data) {
}
}
}
}
// Exit the loop if callback signalled to exit,
return
data_len
;
// or "connection close" opcode received.
if
((
*
bits
&
0x0f
)
==
WEBSOCKET_OPCODE_CONNECTION_CLOSE
)
{
return
data_len
;
stop
=
1
;
}
// Not breaking the loop, process next websocket frame.
}
else
{
}
else
{
// Buffering websocket request
// Buffering websocket request
if
((
n
=
pull
(
NULL
,
conn
,
conn
->
buf
+
conn
->
data_len
,
if
((
n
=
pull
(
NULL
,
conn
,
conn
->
buf
+
conn
->
data_len
,
...
...
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