include gateway handling into the event loop
This commit is contained in:
@@ -62,6 +62,11 @@ void dc_gateway_set_login(dc_gateway_t gw, dc_account_t login);
|
||||
void dc_gateway_set_callback(dc_gateway_t gw, dc_gateway_event_callback_t c,
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* Returns the socket of the current gateway handle.
|
||||
*/
|
||||
int dc_gateway_socket(dc_gateway_t gw);
|
||||
|
||||
/**
|
||||
* Connect the given gateway. Does nothing if the gateway is already
|
||||
* connected.
|
||||
@@ -80,12 +85,20 @@ void dc_gateway_disconnect(dc_gateway_t gw);
|
||||
bool dc_gateway_connected(dc_gateway_t gw);
|
||||
|
||||
/**
|
||||
* Process the queue of data that came from the websocket. Since the
|
||||
* gateway handle is not part of whole event_base_loop() shebang, this
|
||||
* must be called individually. dc_loop_once() will do this for you, if
|
||||
* you opt to use dc_loop() (which you should).
|
||||
* This method should be called whenever data is available on the socket of
|
||||
* the gateway that should be read and processed. This function returns false
|
||||
* if a disconnect happened, and no more calls to this function should be made
|
||||
* in the feature. This method is useful if you are using an event loop (or
|
||||
* select) and wish to notify the gateway that data is ready.
|
||||
*/
|
||||
void dc_gateway_process(dc_gateway_t gw);
|
||||
bool dc_gateway_process_read(dc_gateway_t gw);
|
||||
|
||||
/**
|
||||
* This method should be called whenever the socket is ready to send data. The
|
||||
* method will check internal queues for messages that require sending, and will
|
||||
* also handle the heartbeat. If the gateway closed this function returns false.
|
||||
*/
|
||||
bool dc_gateway_process_write(dc_gateway_t gw);
|
||||
|
||||
/**
|
||||
* utility function to make a websocket frame
|
||||
|
||||
Reference in New Issue
Block a user