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
a3a63f7e
Commit
a3a63f7e
authored
Feb 06, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using mg_connection::callback_param for mg_iterate_over_connection()
parent
c9036f3a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
5 deletions
+6
-5
API.md
docs/API.md
+3
-3
websocket.c
examples/websocket.c
+1
-1
mongoose.c
mongoose.c
+1
-1
mongoose.h
mongoose.h
+1
-0
No files found.
docs/API.md
View file @
a3a63f7e
...
@@ -131,9 +131,9 @@ is returned.
...
@@ -131,9 +131,9 @@ is returned.
This is an interface primarily designed to push arbitrary data to websocket
This is an interface primarily designed to push arbitrary data to websocket
connections at any time. This function could be called from the IO thread only.
connections at any time. This function could be called from the IO thread only.
When it returns, an IO thread calls `
func()
` on each active connection,
When it returns, an IO thread calls `
func()
` on each active connection,
passing `
param
` as
an extra parameter. It is allowed to call `
mg_send_data()
` or
passing `
param
` as
`
struct mg_connection::callback_param
`.
`
mg_websocket_write()
` within a callback, cause `
func
` is executed in the
It is allowed to call `
mg_send_data()
` or `
mg_websocket_write()
` within a
context of the IO thread.
c
allback, cause `
func
` is executed in the c
ontext of the IO thread.
void mg_send_status(struct mg_connection *, int status_code);
void mg_send_status(struct mg_connection *, int status_code);
void mg_send_header(struct mg_connection *, const char *name,
void mg_send_header(struct mg_connection *, const char *name,
...
...
examples/websocket.c
View file @
a3a63f7e
...
@@ -6,7 +6,7 @@ extern const char *find_embedded_file(const char *, size_t *);
...
@@ -6,7 +6,7 @@ extern const char *find_embedded_file(const char *, size_t *);
static
int
iterate_callback
(
struct
mg_connection
*
c
)
{
static
int
iterate_callback
(
struct
mg_connection
*
c
)
{
if
(
c
->
is_websocket
)
{
if
(
c
->
is_websocket
)
{
char
buf
[
20
];
char
buf
[
20
];
int
len
=
snprintf
(
buf
,
sizeof
(
buf
),
"%d"
,
*
(
int
*
)
c
->
c
onnection
_param
);
int
len
=
snprintf
(
buf
,
sizeof
(
buf
),
"%d"
,
*
(
int
*
)
c
->
c
allback
_param
);
mg_websocket_write
(
c
,
1
,
buf
,
len
);
mg_websocket_write
(
c
,
1
,
buf
,
len
);
}
}
return
MG_REQUEST_PROCESSED
;
return
MG_REQUEST_PROCESSED
;
...
...
mongoose.c
View file @
a3a63f7e
...
@@ -3938,7 +3938,7 @@ void mg_iterate_over_connections(struct mg_server *server, mg_handler_t handler,
...
@@ -3938,7 +3938,7 @@ void mg_iterate_over_connections(struct mg_server *server, mg_handler_t handler,
LINKED_LIST_FOREACH
(
&
server
->
active_connections
,
lp
,
tmp
)
{
LINKED_LIST_FOREACH
(
&
server
->
active_connections
,
lp
,
tmp
)
{
conn
=
LINKED_LIST_ENTRY
(
lp
,
struct
connection
,
link
);
conn
=
LINKED_LIST_ENTRY
(
lp
,
struct
connection
,
link
);
conn
->
mg_conn
.
c
onnection
_param
=
param
;
conn
->
mg_conn
.
c
allback
_param
=
param
;
handler
(
&
conn
->
mg_conn
);
handler
(
&
conn
->
mg_conn
);
}
}
}
}
...
...
mongoose.h
View file @
a3a63f7e
...
@@ -55,6 +55,7 @@ struct mg_connection {
...
@@ -55,6 +55,7 @@ struct mg_connection {
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
;
// Used by mg_iterate_over_connections()
};
};
struct
mg_server
;
// Opaque structure describing server instance
struct
mg_server
;
// Opaque structure describing server instance
...
...
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