Some new commands like start_fax will require a multitude of options.
Also, the way we set SIP headers in messages is not very good (single parameter as a string with headers separated with ‘\n’)
So let’s use JSON to send parameters to the underlying pj controlling code.
This will simplify updating the interface with javascript:
basically at javascript side each method should require only the entity id (call_id, account_id, transport_id etc) and an object with parameters.
So we would not need to update those interfaces anymore and all non-object-creation methods would be like this:
We would stringify the params object and pass it as a string parameter to the methods.
Then at the c side we would just need to parse the string using some library like rapidjson.
Obs: note that we could use NAPI to interface passing the object data.
However, we might eventually need to reuse the core c code in another project/language and so it is better have the processing of JSON at the core.
Rationale:
Some new commands like start_fax will require a multitude of options. Also, the way we set SIP headers in messages is not very good (single parameter as a string with headers separated with ‘\n’) So let’s use JSON to send parameters to the underlying pj controlling code.
This will simplify updating the interface with javascript: basically at javascript side each method should require only the entity id (call_id, account_id, transport_id etc) and an object with parameters. So we would not need to update those interfaces anymore and all non-object-creation methods would be like this:
We would stringify the params object and pass it as a string parameter to the methods. Then at the c side we would just need to parse the string using some library like rapidjson. Obs: note that we could use NAPI to interface passing the object data. However, we might eventually need to reuse the core c code in another project/language and so it is better have the processing of JSON at the core.
JSON libraries to check: https://rapidjson.org/ https://github.com/Tencent/rapidjson/blob/master/example/simplereader/simplereader.cpp
https://zserge.com/jsmn/
https://gitee.com/xuzd/cJSON
https://github.com/skeeto/pdjson
https://jansson.readthedocs.io/