Skip to content

Refactor Signaling sources to make Include_i.h independent of libwebsockets #2141

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

vikramdattu
Copy link
Contributor

  • This way, one could write a new CMakeLists.txt, with ApiCalls using different websocket implementation
  • One should simply remove existing Signaling.c and LwsApiCalls.c from compilation and add their own

What was changed?

  • Include_i.h and other SIgnaling files modified to contain libwebsockets dependency to C files

Why was it changed?

  • To make it easier to swap the signaling implementation keeping headers re-usable

@@ -65,6 +63,7 @@ extern "C" {
#include <arpa/inet.h>
#include <fcntl.h>
#include <netinet/tcp.h>
#include <poll.h>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this was earlier satisfied from libwebsockets.h

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make this platform independent, I think we should pass it as a compiler flag and only include if true.

cmake:

include(CheckIncludeFile)
check_include_file("poll.h" HAVE_POLL_H)

if(HAVE_POLL_H)
    add_definitions(-DHAVE_POLL_H=1)
endif()

C:

#ifdef HAVE_POLL_H
#include <poll.h>
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe similar for ifaddrs.h

@@ -167,11 +167,14 @@ extern "C" {
// Encoded max ice server infos string len
#define MAX_ENCODED_ICE_SERVER_INFOS_STR_LEN (MAX_ICE_SERVER_INFOS_STR_LEN + ICE_SERVER_INFO_TEMPLATE_BLOAT_SIZE)

// Alignment bytes for libwebsockets (Internally, it might end up using lesser than 16)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LWS_PRE is libwebsockets defined macro! We just use 16 bytes extra than required by message. libwebsockets can freely use these extra 16 bytes for its alignment needs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it would eventually make sense to have an "ApiCalls" interface to abstract away lws (similar to how Tls.h is setup).

Copy link
Contributor Author

@vikramdattu vikramdattu May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first thoughts were to have a function pointers structure and have it initialised with the required ApiCalls by the implementation. (The default would be the libwebsockets).
I think that would be more involved re-structuring. This one simply keeps everything at places just making headers more implementation dependent.

Copy link
Contributor

@sirknightj sirknightj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, thanks for all the hard work!

@@ -167,11 +167,14 @@ extern "C" {
// Encoded max ice server infos string len
#define MAX_ENCODED_ICE_SERVER_INFOS_STR_LEN (MAX_ICE_SERVER_INFOS_STR_LEN + ICE_SERVER_INFO_TEMPLATE_BLOAT_SIZE)

// Alignment bytes for libwebsockets (Internally, it might end up using lesser than 16)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it would eventually make sense to have an "ApiCalls" interface to abstract away lws (similar to how Tls.h is setup).

…bsockets

 - This way, one could write a new CMakeLists.txt, with ApiCalls using different websocket implementation
 - One should simply remove existing Signaling.c and LwsApiCalls.c from compilation and add their own
@vikramdattu vikramdattu force-pushed the refactor/make_headers_libwebsockets_independent branch from e90a7c8 to f2be2ca Compare May 23, 2025 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants