-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REVIEW] Integrate libwebsockets library #5683
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
Comments inline.
.gitmodules
Outdated
@@ -13,3 +13,6 @@ | |||
path = deps/nodesetLoader | |||
url = https://github.com/open62541/nodesetLoader | |||
branch = master | |||
[submodule "deps/libwebsockets"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use a git submodule.
99% of users should install libwebsockets via a package manager.
And the remaining 1% know how to do it themselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the submodule. The users should manually install or use a distorted package.
CMakeLists.txt
Outdated
set(LIBWEBSOCKETS_FOUND 0) | ||
endif() | ||
endif() | ||
if(NOT LIBWEBSOCKETS_FOUND) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throw an exception when not found.
The find_package
thing allows users to manually define the folders.
That should be the only way of doing things.
Like for OpenSSL/mbedTLS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not modify settings.
Abort with a warning when you cannot build.
CMakeLists.txt
Outdated
#Libwebsockets | ||
if(UA_ENABLE_LWS) | ||
if(NOT LIBWEBSOCKETS_FOUND) | ||
add_dependencies(open62541-object websockets_shared) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed. LIBWEBSOCKETS_FOUND has to be true.
arch/eventloop_lws_http.c
Outdated
const UA_DataType *type; | ||
UA_Boolean required; | ||
} HTTPSendParameters[HTTP_PARAMETERSSIZE] = { | ||
{{0, UA_STRING_STATIC("url")}, &UA_TYPES[UA_TYPES_STRING], true}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean address instead of url.
The url would include the port and path as well.
How would this be extended for https?
You can already add this as a comment.
arch/eventloop_lws_http.c
Outdated
} | ||
|
||
static UA_StatusCode | ||
HTTP_sendWithConnection(UA_ConnectionManager *cm, uintptr_t connectionId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTTP is synchronous.
So you have to wait for the previous request to receive a response before sending the next request.
Ensure there can be no misuse.
So either
- block sending requests while still waiting for a response
- Add the next requests to a list and send them out automatically later on.
arch/lws/ua_lws_adapter.c
Outdated
} | ||
|
||
static const struct lws_event_loop_ops event_loop_ops_custom = { | ||
.name = "custom", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use tabs
|
||
UA_KeyValueMap map = {paramsSize, params}; | ||
|
||
cm->openConnection(cm, NULL, NULL, NULL, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a callback to log the received result.
Also add the handling of failure cases where the remote side does not exist.
How are HTTP status codes lik 404 handled?
Given to the callback as part of the parameter map?
tools/cmake/Findlibwebsockets.cmake
Outdated
/usr/local/include | ||
/usr/include | ||
) | ||
pkg_search_module(LIBWEBSOCKETS REQUIRED libwebsockets) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires pkg-config and is only available for Linux.
The previous cmake file was multi-platform.
And it should stay that way.
On more point. Try to get as low as possible in the version requirements. |
edee065
to
a7bf9bc
Compare
ea334fc
to
1401b4d
Compare
2687aeb
to
e4e5741
Compare
37c498e
to
2272aa2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. A few comments were unresolved from last time.
Let’s merge this for 1.4!
.gitmodules
Outdated
@@ -13,3 +13,6 @@ | |||
path = deps/nodesetLoader | |||
url = https://github.com/open62541/nodesetLoader | |||
branch = master | |||
[submodule "deps/libwebsockets"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the submodule. The users should manually install or use a distorted package.
CMakeLists.txt
Outdated
set(LIBWEBSOCKETS_FOUND 0) | ||
endif() | ||
endif() | ||
if(NOT LIBWEBSOCKETS_FOUND) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not modify settings.
Abort with a warning when you cannot build.
arch/eventloop_lws_http.c
Outdated
|
||
static UA_StatusCode | ||
HTTP_eventSourceDelete(UA_ConnectionManager *cm) { | ||
UA_String_clear(&cm->eventSource.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still unresolved
* Open Connection Parameters: | ||
* - 0:hostname [string]: Hostname (or IPv4/v6 address) of the connection (required). | ||
* - 0:port [uint16]: Port of the target host (default: 443). | ||
* - 0:path [string]: Path is the string of information that comes after the top level domain name (default: /). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way I understand it, the connection will stay open for multiple requests.
The path, method and data should be parameters for sendWithConnection
, not here.
fae739c
to
b4fd3d5
Compare
b4fd3d5
to
6bf5e32
Compare
Rebased on master. |
This PR integrates libwebsockets library into the open62541 stack. The integration is done via the adapter in arch/lws. This adapter acts as a custom "event library" interface layer between the lws event lib support and the open62541 event loop. By integrating in this way, the libwebsockets library makes use of the open62541 event loop, which allows for a perfect integration into the stack.