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
94f63787
Commit
94f63787
authored
Mar 24, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restored void * parameter for iterate_over_connections()
parent
367f5df3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
11 deletions
+13
-11
websocket.c
examples/websocket.c
+3
-3
mongoose.c
mongoose.c
+7
-6
mongoose.h
mongoose.h
+3
-2
No files found.
examples/websocket.c
View file @
94f63787
...
@@ -9,10 +9,10 @@
...
@@ -9,10 +9,10 @@
extern
const
char
*
find_embedded_file
(
const
char
*
,
size_t
*
);
extern
const
char
*
find_embedded_file
(
const
char
*
,
size_t
*
);
static
int
iterate_callback
(
struct
mg_connection
*
c
,
enum
mg_event
ev
)
{
static
int
iterate_callback
(
struct
mg_connection
*
c
,
enum
mg_event
ev
)
{
static
int
counter
=
0
;
if
(
ev
==
MG_POLL
&&
c
->
is_websocket
)
{
if
(
ev
==
MG_POLL
&&
c
->
is_websocket
)
{
char
buf
[
20
];
char
buf
[
20
];
int
len
=
snprintf
(
buf
,
sizeof
(
buf
),
"%d"
,
counter
++
);
int
len
=
snprintf
(
buf
,
sizeof
(
buf
),
"%lu"
,
(
unsigned
long
)
*
(
time_t
*
)
c
->
callback_param
);
mg_websocket_write
(
c
,
1
,
buf
,
len
);
mg_websocket_write
(
c
,
1
,
buf
,
len
);
}
}
return
MG_TRUE
;
return
MG_TRUE
;
...
@@ -58,7 +58,7 @@ int main(void) {
...
@@ -58,7 +58,7 @@ int main(void) {
current_timer
=
time
(
NULL
);
current_timer
=
time
(
NULL
);
if
(
current_timer
-
last_timer
>
0
)
{
if
(
current_timer
-
last_timer
>
0
)
{
last_timer
=
current_timer
;
last_timer
=
current_timer
;
mg_iterate_over_connections
(
server
,
iterate_callback
);
mg_iterate_over_connections
(
server
,
iterate_callback
,
&
current_timer
);
}
}
}
}
...
...
mongoose.c
View file @
94f63787
...
@@ -4254,20 +4254,21 @@ struct mg_iterator {
...
@@ -4254,20 +4254,21 @@ struct mg_iterator {
mg_handler_t
cb
;
mg_handler_t
cb
;
void
*
param
;
void
*
param
;
};
};
union
variant
{
mg_handler_t
cb
;
void
*
p
;
};
static
void
iter
(
struct
ns_connection
*
nsconn
,
enum
ns_event
ev
,
void
*
param
)
{
static
void
iter
(
struct
ns_connection
*
nsconn
,
enum
ns_event
ev
,
void
*
param
)
{
if
(
ev
==
NS_POLL
)
{
if
(
ev
==
NS_POLL
)
{
union
variant
*
variant
=
(
union
variant
*
)
param
;
struct
mg_iterator
*
it
=
(
struct
mg_iterator
*
)
param
;
struct
connection
*
c
=
(
struct
connection
*
)
nsconn
->
connection_data
;
struct
connection
*
c
=
(
struct
connection
*
)
nsconn
->
connection_data
;
variant
->
cb
(
&
c
->
mg_conn
,
MG_POLL
);
c
->
mg_conn
.
callback_param
=
it
->
param
;
it
->
cb
(
&
c
->
mg_conn
,
MG_POLL
);
}
}
}
}
// Apply function to all active connections.
// Apply function to all active connections.
void
mg_iterate_over_connections
(
struct
mg_server
*
server
,
mg_handler_t
cb
)
{
void
mg_iterate_over_connections
(
struct
mg_server
*
server
,
mg_handler_t
cb
,
union
variant
variant
=
{
cb
};
void
*
param
)
{
ns_iterate
(
&
server
->
ns_server
,
iter
,
&
variant
);
struct
mg_iterator
it
=
{
cb
,
param
};
ns_iterate
(
&
server
->
ns_server
,
iter
,
&
it
);
}
}
static
int
get_var
(
const
char
*
data
,
size_t
data_len
,
const
char
*
name
,
static
int
get_var
(
const
char
*
data
,
size_t
data_len
,
const
char
*
name
,
...
...
mongoose.h
View file @
94f63787
...
@@ -48,13 +48,14 @@ struct mg_connection {
...
@@ -48,13 +48,14 @@ struct mg_connection {
}
http_headers
[
30
];
}
http_headers
[
30
];
char
*
content
;
// POST (or websocket message) data, or NULL
char
*
content
;
// POST (or websocket message) data, or NULL
size_t
content_len
;
// content
length
size_t
content_len
;
// Data
length
int
is_websocket
;
// Connection is a websocket connection
int
is_websocket
;
// Connection is a websocket connection
int
status_code
;
// HTTP status code for HTTP error handler
int
status_code
;
// HTTP status code for HTTP error handler
int
wsbits
;
// First byte of the websocket frame
int
wsbits
;
// First byte of the websocket frame
void
*
server_param
;
// Parameter passed to mg_add_uri_handler()
void
*
server_param
;
// Parameter passed to mg_add_uri_handler()
void
*
connection_param
;
// Placeholder for connection-specific data
void
*
connection_param
;
// Placeholder for connection-specific data
void
*
callback_param
;
// Needed by mg_iterate_over_connections()
};
};
struct
mg_server
;
// Opaque structure describing server instance
struct
mg_server
;
// Opaque structure describing server instance
...
@@ -80,7 +81,7 @@ const char **mg_get_valid_option_names(void);
...
@@ -80,7 +81,7 @@ const char **mg_get_valid_option_names(void);
const
char
*
mg_get_option
(
const
struct
mg_server
*
server
,
const
char
*
name
);
const
char
*
mg_get_option
(
const
struct
mg_server
*
server
,
const
char
*
name
);
void
mg_set_listening_socket
(
struct
mg_server
*
,
int
sock
);
void
mg_set_listening_socket
(
struct
mg_server
*
,
int
sock
);
int
mg_get_listening_socket
(
struct
mg_server
*
);
int
mg_get_listening_socket
(
struct
mg_server
*
);
void
mg_iterate_over_connections
(
struct
mg_server
*
,
mg_handler_t
);
void
mg_iterate_over_connections
(
struct
mg_server
*
,
mg_handler_t
,
void
*
);
void
mg_wakeup_server
(
struct
mg_server
*
);
void
mg_wakeup_server
(
struct
mg_server
*
);
struct
mg_connection
*
mg_connect
(
struct
mg_server
*
,
const
char
*
,
int
,
int
);
struct
mg_connection
*
mg_connect
(
struct
mg_server
*
,
const
char
*
,
int
,
int
);
...
...
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