Nauja / libws

Wrapper over libwebsockets for easy ws

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

libws

CI CI Docs Documentation Status GitHub license

Wrapper over libwebsockets for websockets.

Why

libwebsockets is a popular library with a generic interface for http/1, http/2, websockets, MQTT, and while it's great to have a generic interface, it also makes it more complicated to get started if you only want to use it for websockets. So, this library aims to provide a simpler interface over libwebsockets to remove some of the boilerplate required to create a websockets server or client.

Examples

WIP

Build Manually

Copy the files ws.c and ws.h into an existing project.

Comment or uncomment the defines at the top of ws.h depending on your configuration:

/* Define to 1 if you have the <stdio.h> header file. */
#ifndef HAVE_STDIO_H
#define HAVE_STDIO_H 1
#endif

/* Define to 1 if you have the <stdlib.h> header file. */
#ifndef HAVE_STDLIB_H
#define HAVE_STDLIB_H 1
#endif

/* Define to 1 if you have the <sys/stat.h> header file. */
#ifndef HAVE_SYS_STAT_H
#define HAVE_SYS_STAT_H 1
#endif

...

You should now be able to compile this library correctly.

Build with CMake

Tested with CMake >= 3.13.4:

git clone https://github.com/Nauja/libws.git
cd libws
git submodule init
git submodule update
mkdir build
cd build
cmake ..

CMake will correctly configure the defines at the top of ws.h for your system.

You can then build this library manually as described above, or by using:

make

This will generate libws.a if building as a static library and liblibws.so in the build directory.

You can change the build process with a list of different options that you can pass to CMake. Turn them on with On and off with Off:

  • -DLIBWS_STATIC=On: Enable building as static library. (on by default)
  • -DLIBWS_UNIT_TESTING=On: Enable building the tests. (on by default)
  • -DLIBWS_DOXYGEN=On: Enable building the docs. (off by default)

Build with Visual Studio

Generate the Visual Studio solution with:

mkdir build
cd build
cmake .. -G "Visual Studio 16 2019"

You can now open build/libws.sln and compile the library.

License

Licensed under the MIT License.

About

Wrapper over libwebsockets for easy ws

License:MIT License


Languages

Language:C 56.3%Language:CMake 43.7%