Skip to content

artnum/ananke

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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