qjs-net

This package aims to provide simple, minimal and essential networking infrastructures for QuickJS. (Derived from minnet-quickjs)

Currently, it can:

Usage

Requirements:

To use qjs-net in your QuickJS project, run following commands:

cd your_project_dir
git clone https://github.com/rsenn/qjs-net
cd qjs-net
git submodule update --init
cd build
cmake ..

Alternatively use either premake or ninja:

premake5 gmake

or

ninja -C build

These alternative build methods can’t invoke the compilation of libwebsockets, therefore you have to build and install it manually before you can compile qjs-net:

cd qjs-net
. build-libwebsockets.sh

TYPE=Release builddir=libwebsockets/build \
  build_libwebsockets 
  
make -C libwebsockets/build install

You may add the variable OPENSSL_PREFIX (e.g. OPENSSL_PREFIX=/opt/libressl-3.5.1) in front of that command when building against a custom SSL library build.

cd your_project_dir git clone https://github.com/rsenn/qjs-net cd qjs-net/build cmake ..


In your JS script:
```javascript
import * as net from 'net.so';

net.server(options): Create a WebSocket server and listen to host:port.

options: an object with following properties:

net.client(options): Create a WebSocket client and connect to a server.

options: an object with following properties:

MinnetWebsocket instance

contains socket to a server or client. You can use these methods to communicate:

fetch(url): Get resources from url

url: a string to download resources from.
Returns MinnetResponse object that you can use these
Methods:

Properties:

Check out example.mjs