Webcom C SDK
Control the websocket connection to the datasync server
wc_datasync_context_twc_datasync_init (wc_context_t *ctx)
 
int wc_datasync_keepalive (wc_context_t *ctx)
 
void wc_datasync_connect (wc_context_t *ctx)
 
void wc_datasync_close_cnx (wc_context_t *ctx)
 

Detailed Description

Function Documentation

◆ wc_datasync_close_cnx()

void wc_datasync_close_cnx ( wc_context_t ctx)

Gracefully closes the connection to the Webcom datasync server.

Note
the user-defined wc_on_event_cb_t callback will be triggered with a WC_EVENT_ON_CNX_CLOSED event once the connection has been closed. The higher level callback wc_eli_callbacks::on_disconnected will be called if the context is managed by libev.
Parameters
ctxthe context

◆ wc_datasync_connect()

void wc_datasync_connect ( wc_context_t ctx)

Connects or reconnects a disconnected Webcom context

This function tries to (re)establish a connection to a Webcom server for a context whose connection is disconnected. This is the case when the following Webcom events have been dispatched to the user callback:

  • WC_EVENT_ON_CNX_CLOSED
  • WC_EVENT_ON_CNX_ERROR
Parameters
ctxthe context

◆ wc_datasync_init()

wc_datasync_context_t* wc_datasync_init ( wc_context_t ctx)

initializes the datasync service for a Webcom context

This function must be have been called once before performing any datasync related operation. Note that wc_datasync_connect() will call this function before trying to connect to the server, if it had not been called already.

Parameters
ctxthe Webcom context
Returns
a pointer to an opaque structure representing the datasync service

◆ wc_datasync_keepalive()

int wc_datasync_keepalive ( wc_context_t ctx)

Function that keeps the connection to the webcom server alive.

The server will singlehandledly close the connection if there is no activity from the client in the last 60 seconds. Call this function periodically to avoid this.

Note
If you use one of the libev integration, you don't need to call this function.
Parameters
ctxthe context