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
dcbd1cbb
Commit
dcbd1cbb
authored
Sep 08, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved pubsub example to websocket_chat
parent
a3b568f4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
6 deletions
+18
-6
Makefile
examples/websocket_chat/Makefile
+12
-0
index.html
examples/websocket_chat/index.html
+3
-3
websocket_chat.c
examples/websocket_chat/websocket_chat.c
+3
-3
No files found.
examples/websocket_chat/Makefile
0 → 100644
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
examples/
pubsub
.html
→
examples/
websocket_chat/index
.html
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>
...
...
examples/websocket
2
.c
→
examples/websocket
_chat/websocket_chat
.c
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
);
...
...
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