Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mongoose
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ganil-acq
GANILinux
linux-service
library
mongoose
Commits
8354319e
Commit
8354319e
authored
7 years ago
by
Ruslan Valiullin
Committed by
Cesanta Bot
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
websocket_chat added MG_EV_HTTP_REQUEST
PUBLISHED_FROM=6f5e1b4a97ada21025f892d3348808bffb469dfa
parent
f9596cc1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/websocket_chat/Makefile
+1
-1
1 addition, 1 deletion
examples/websocket_chat/Makefile
examples/websocket_chat/websocket_chat.c
+7
-0
7 additions, 0 deletions
examples/websocket_chat/websocket_chat.c
with
8 additions
and
1 deletion
examples/websocket_chat/Makefile
+
1
−
1
View file @
8354319e
PROG
=
websocket_chat
MODULE_CFLAGS
=
-DMG_ENABLE_FILESYSTEM
=
0
MODULE_CFLAGS
=
-DMG_ENABLE_FILESYSTEM
=
1
include
../examples.mk
This diff is collapsed.
Click to expand it.
examples/websocket_chat/websocket_chat.c
+
7
−
0
View file @
8354319e
...
...
@@ -7,6 +7,7 @@
static
sig_atomic_t
s_signal_received
=
0
;
static
const
char
*
s_http_port
=
"8000"
;
static
struct
mg_serve_http_opts
s_http_server_opts
;
static
void
signal_handler
(
int
sig_num
)
{
signal
(
sig_num
,
signal_handler
);
// Reinstantiate signal handler
...
...
@@ -46,6 +47,10 @@ static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
broadcast
(
nc
,
d
);
break
;
}
case
MG_EV_HTTP_REQUEST
:
{
mg_serve_http
(
nc
,
(
struct
http_message
*
)
ev_data
,
s_http_server_opts
);
break
;
}
case
MG_EV_CLOSE
:
{
/* Disconnect. Tell everybody. */
if
(
is_websocket
(
nc
))
{
...
...
@@ -69,6 +74,8 @@ int main(void) {
nc
=
mg_bind
(
&
mgr
,
s_http_port
,
ev_handler
);
mg_set_protocol_http_websocket
(
nc
);
s_http_server_opts
.
document_root
=
"."
;
// Serve current directory
s_http_server_opts
.
enable_directory_listing
=
"yes"
;
printf
(
"Started on port %s
\n
"
,
s_http_port
);
while
(
s_signal_received
==
0
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment