https://github.com/artnum/ananke
Trying out some ideas
https://github.com/artnum/ananke
libwebsockets locking-scheduler synchronization websocket-server
Last synced: about 1 year ago
JSON representation
Trying out some ideas
- Host: GitHub
- URL: https://github.com/artnum/ananke
- Owner: artnum
- License: mit
- Created: 2021-03-14T18:10:38.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-22T13:58:08.000Z (about 5 years ago)
- Last Synced: 2025-01-21T13:25:46.096Z (over 1 year ago)
- Topics: libwebsockets, locking-scheduler, synchronization, websocket-server
- Language: C
- Homepage:
- Size: 75.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ananké
websocket server mainly develop to test some ideas. The name is from the greek deity of inevitability, compulsion and necessity (the name is in french : Ananké |a.nan.ke|). The developpment sparked from locking and synchronization problems so the project might end up doing just that.
## AKEncoding and Ananké-protocol
On the Web, JSON or XML are nice to send data to the browser. But on the server side it might be a good idea to have some other format for serializing data. The Ananké-protocol is an experiment in an asymetric encoding for a protocol.
On the sending side, server -> client, JSON is used. Nothing interesting here.
On the receiving side, server <- client, AKEncoding is used. AKEncoding serialize javascript object into BER inspired encoding. It's TLV encoding with the name of each field stuffed in between. So it is a TLnLvNV encoding :
* T -> Tag, 3 chars long : INT, FLO, NUL, BOO, OBJ, STR, HEX, BST
* Ln -> Byte length of the name, 8 chars long, positive integer base36 encoded
* Lv -> Byte length of the value, 8 chars long, positive integer base36 encoded
* N -> Name, name of the value, _Ln_ bytes long, any utf-8 string
* V -> Value itself, _Lv_ bytes long, depend on the type :
- Integer (INT), float (FLO) : string represention of the number with . or , for decimal speration, base 10.
- Boolean (BOO) : either '1' or '0' (so length is always 1)
- Null (NUL) : No value
- String (STR), hex-encoded string (HEX), byte string (BST) : utf-8 encoded string, HEX is any string hex encoded, BST is nothing yet but might be something along the idea of a any binary value base64 encoded ...
- Object or Array (OBJ) : a set of any above value, array are object with field name of 0, 1, 2, ... as javascript array have no particular type (except TypedArray but it doesn't matter much)
The structure of AKEncoding allows to go through without first parsing it (which has not been done here but it could be done) and it's streamable.
Basically the client encode everything it sends into AKEncoding and the server encode everything it sends into JSON.
## i18n
As it's been developp in a country with several official language, the first question that comes out when presenting a software is "is it tranlated to german, french or italian" ? So from the beginning the project added the possibility to have error message in several language. It's a bit rough yet as I have no strategy for that now, but trying some ideas around that is part of the project.
## Licence
MIT, see LICENCE