From 619ef5eb17831c4c6550f95fddb496f00a9f7cb2 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Fri, 1 Jan 2021 14:50:45 +0000 Subject: [PATCH] smd: add use class base index In addition to the well-known classes, add a user class base bit offset so distributed user applications can cleanly send messages using SMD --- include/libwebsockets/lws-smd.h | 2 ++ lib/system/smd/README.md | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/libwebsockets/lws-smd.h b/include/libwebsockets/lws-smd.h index 66484d734..22992540c 100644 --- a/include/libwebsockets/lws-smd.h +++ b/include/libwebsockets/lws-smd.h @@ -52,6 +52,8 @@ enum { * Something happened on the network, eg, link-up or DHCP, or captive * portal state update */ + + LWSSMDCL_USER_BASE_BITNUM = 24 }; /** diff --git a/lib/system/smd/README.md b/lib/system/smd/README.md index c61ef4527..34ef43f25 100644 --- a/lib/system/smd/README.md +++ b/lib/system/smd/README.md @@ -44,13 +44,18 @@ appear as soon as a participant appears that wants them. The message generation action should be bypassed without error in the case lws_smd_msg_alloc() returns NULL. +Various well-known high level classes are defined but also a bit index +`LWSSMDCL_USER_BASE_BITNUM`, which can be used by user code to define up to 8 +private classes, with class bit values `(1 << LWSSMDCL_USER_BASE_BITNUM)` thru +`(1 << (LWSSMDCL_USER_BASE_BITNUM + 7))` + ## Messaging guarantees Sent messages are delivered to all registered participants whose class mask indicates they want it, including the sender. The send apis are threadsafe. Locally-delivered message delivery callbacks occur from lws event loop thread -context 0 (the only one in the default case LWS_MAX_SMP = 1). Clients in +context 0 (the only one in the default case `LWS_MAX_SMP` = 1). Clients in different processes receive callbacks from the thread context of their UDS networking thread.