Skip to content

Commit c6dab1c

Browse files
committed
README: general design guidelines
1 parent dbb0490 commit c6dab1c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,29 @@ If you run it on another platform, kindly let us know so that we can share the
1414
information. If you made some modifications to make it work on your platform,
1515
please consider opening a pull request so it gets integrated here.
1616

17+
## General design
18+
19+
This SDK is meant to be used in a event-loop, and does not provide its own
20+
event loop. This means the SDK users are responsible for implementing the event
21+
loop (we may provide one in the future). The general steps to follow are:
22+
23+
1. establish a connection to the Webcom server using `wc_cnx_new()`,
24+
2. query the file descriptor for that connection using `wc_cnx_get_fd()`,
25+
3. poll that file descriptor in your event loop for write events,
26+
4. call `wc_cnx_on_readable()` whenever this event occurs; if there is any
27+
Webcom service-level event you should be aware of, this will automatically
28+
trigger the callback you passed to `wc_cnx_new()` with the relevant
29+
informations as parameters.
30+
31+
**Note:** The Webcom server **will close any inactive connection** after a 1
32+
minute timeout. The event loop is responsible for calling `wc_cnx_keepalive()`
33+
periodically (e.g. every 50 seconds) to keep the connection alive.
34+
35+
The above-described logic is implemented in the provided examples, using
36+
**libev** as an event loop. A "boilerplate" project is also available in the
37+
[examples/cmake-boilerplate-project/](examples/cmake-boilerplate-project/)
38+
folder, feel free to copy and adapt it to your needs.
39+
1740
## Get the SDK
1841

1942
There are serveral ways of getting this SDK. The easiest one is to download a

0 commit comments

Comments
 (0)