Skip to content

<feature> Lower-level, non event-based APIs too #47

@Theldus

Description

@Theldus

Description

In issue #24, was discussed the possibility of having a low-level API for finer control over wsServer.

This is a much-desired feature: while the current API provides a clean and intuitive way on how to use web sockets, it hides many implementation details, such as the dynamic memory allocations that occur under the hood.

A lower-level, non-event-based approach becomes interesting for using wsServer in embedded systems, where memory usage and OS resources are scarce.

Additional routines like the ones described below might be interesting in this scenario:

  • ws_listen: create the socket and let the server listen on a port

  • ws_accept: equivalent to accept. Accepts a single connection and performs the handshake. From this point on, it becomes possible to send and receive messages.

  • ws_receiveframe: Receives a single frame (control frame or not) and saves it in a buffer provided by the user, does not perform dynamic memory allocations. CONT-type frames require multiple invocations to this routine. Return parameters and variables to inform frame content, type, error, and success conditions are important.

(I leave the parameters and return of the functions open, as this can change at any time).

It is also important to leave the management of client lists, pthreads, locks, etc, to the event-based implementation (or not, I'm still thinking about it). The idea is that this API becomes the foundation of the current API: which is higher-level and event-based.

PS: Any help on this issue is greatly appreciated as it requires a lot of rework of the source code =).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions