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
dcbd1cbb
Commit
dcbd1cbb
authored
10 years ago
by
Sergey Lyubka
Browse files
Options
Downloads
Patches
Plain Diff
Moved pubsub example to websocket_chat
parent
a3b568f4
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/websocket_chat/Makefile
+12
-0
12 additions, 0 deletions
examples/websocket_chat/Makefile
examples/websocket_chat/index.html
+3
-3
3 additions, 3 deletions
examples/websocket_chat/index.html
examples/websocket_chat/websocket_chat.c
+3
-3
3 additions, 3 deletions
examples/websocket_chat/websocket_chat.c
with
18 additions
and
6 deletions
examples/websocket_chat/Makefile
0 → 100644
+
12
−
0
View file @
dcbd1cbb
# Copyright (c) 2014 Cesanta Software
# All rights reserved
PROG
=
websocket_chat
CFLAGS
=
-W
-Wall
-I
../..
-g
-O0
$(
CFLAGS_EXTRA
)
SOURCES
=
$(
PROG
)
.c ../../mongoose.c
$(PROG)
:
$(SOURCES)
$(
CC
)
-o
$(
PROG
)
$(
SOURCES
)
$(
CFLAGS
)
clean
:
rm
-rf
$(
PROG
)
*
.exe
*
.dSYM
*
.obj
*
.exp .
*
o
*
.lib
This diff is collapsed.
Click to expand it.
examples/
pubsub
.html
→
examples/
websocket_chat/index
.html
+
3
−
3
View file @
dcbd1cbb
...
...
@@ -48,7 +48,7 @@
document
.
getElementById
(
'
messages
'
).
appendChild
(
div
);
}
};
window
.
onload
=
function
()
{
document
.
getElementById
(
'
send_button
'
).
onclick
=
function
(
ev
)
{
var
msg
=
document
.
getElementById
(
'
send_input
'
).
value
;
...
...
@@ -74,7 +74,7 @@
connection with Mongoose, making each browser window a websocket client.
Join a room, send messages, and see messages sent by other clients.
</p>
<p>
My ID:
<b><span
id=
"my_id"
></b></span>
</p>
...
...
@@ -88,7 +88,7 @@
<div
id=
"messages"
>
</div>
<p>
<input
type=
"text"
id=
"send_input"
/>
<button
id=
"send_button"
>
Send Message
</button>
...
...
This diff is collapsed.
Click to expand it.
examples/websocket
2
.c
→
examples/websocket
_chat/websocket_chat
.c
+
3
−
3
View file @
dcbd1cbb
...
...
@@ -46,7 +46,7 @@ static int ev_handler(struct mg_connection *conn, enum mg_event ev) {
handle_websocket_message
(
conn
);
return
MG_TRUE
;
}
else
{
mg_send_file
(
conn
,
"
pubsub
.html"
);
// Return MG_MORE after mg_send_file()
mg_send_file
(
conn
,
"
index
.html"
);
// Return MG_MORE after mg_send_file()
return
MG_MORE
;
}
case
MG_WS_CONNECT
:
...
...
@@ -67,10 +67,10 @@ static int ev_handler(struct mg_connection *conn, enum mg_event ev) {
int
main
(
void
)
{
s_server
=
mg_create_server
(
NULL
,
ev_handler
);
mg_set_option
(
s_server
,
"listening_port"
,
"8080"
);
signal
(
SIGTERM
,
signal_handler
);
signal
(
SIGINT
,
signal_handler
);
printf
(
"Started on port %s
\n
"
,
mg_get_option
(
s_server
,
"listening_port"
));
while
(
s_signal_received
==
0
)
{
mg_poll_server
(
s_server
,
100
);
...
...
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