conn: add state checking API
New boolean functions: xmpp_conn_is_connecting() xmpp_conn_is_connected() xmpp_conn_is_disconnected() These functions are backported from UnrealEngine project.
This commit is contained in:
@@ -3,6 +3,9 @@
|
|||||||
- LibreSSL support
|
- LibreSSL support
|
||||||
- New API:
|
- New API:
|
||||||
- xmpp_stanza_get_child_by_name_and_ns()
|
- xmpp_stanza_get_child_by_name_and_ns()
|
||||||
|
- xmpp_conn_is_connecting()
|
||||||
|
- xmpp_conn_is_connected()
|
||||||
|
- xmpp_conn_is_disconnected()
|
||||||
|
|
||||||
0.9.3
|
0.9.3
|
||||||
- PLAIN mechanism is used only when no other mechanisms are supported
|
- PLAIN mechanism is used only when no other mechanisms are supported
|
||||||
|
|||||||
31
src/conn.c
31
src/conn.c
@@ -1002,6 +1002,37 @@ int xmpp_conn_is_secured(xmpp_conn_t * const conn)
|
|||||||
return conn->secured && !conn->tls_failed && conn->tls != NULL ? 1 : 0;
|
return conn->secured && !conn->tls_failed && conn->tls != NULL ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return TRUE if connection is in connecting state and FALSE otherwise
|
||||||
|
*
|
||||||
|
* @ingroup Connections
|
||||||
|
*/
|
||||||
|
int xmpp_conn_is_connecting(xmpp_conn_t * const conn)
|
||||||
|
{
|
||||||
|
return conn->state == XMPP_STATE_CONNECTING ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return TRUE if connection is in connected state and FALSE otherwise
|
||||||
|
*
|
||||||
|
* @ingroup Connections
|
||||||
|
*/
|
||||||
|
int xmpp_conn_is_connected(xmpp_conn_t * const conn)
|
||||||
|
{
|
||||||
|
return conn->state == XMPP_STATE_CONNECTED ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return TRUE if connection is in disconnected state and FALSE otherwise
|
||||||
|
*
|
||||||
|
* @ingroup Connections
|
||||||
|
*/
|
||||||
|
int xmpp_conn_is_disconnected(xmpp_conn_t * const conn)
|
||||||
|
{
|
||||||
|
return conn->state == XMPP_STATE_DISCONNECTED ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* timed handler for cleanup if normal disconnect procedure takes too long */
|
/* timed handler for cleanup if normal disconnect procedure takes too long */
|
||||||
static int _disconnect_cleanup(xmpp_conn_t * const conn,
|
static int _disconnect_cleanup(xmpp_conn_t * const conn,
|
||||||
void * const userdata)
|
void * const userdata)
|
||||||
|
|||||||
@@ -237,6 +237,9 @@ xmpp_ctx_t *xmpp_conn_get_context(xmpp_conn_t * const conn);
|
|||||||
void xmpp_conn_disable_tls(xmpp_conn_t * const conn);
|
void xmpp_conn_disable_tls(xmpp_conn_t * const conn);
|
||||||
int xmpp_conn_is_secured(xmpp_conn_t * const conn);
|
int xmpp_conn_is_secured(xmpp_conn_t * const conn);
|
||||||
void xmpp_conn_set_keepalive(xmpp_conn_t * const conn, int timeout, int interval);
|
void xmpp_conn_set_keepalive(xmpp_conn_t * const conn, int timeout, int interval);
|
||||||
|
int xmpp_conn_is_connecting(xmpp_conn_t * const conn);
|
||||||
|
int xmpp_conn_is_connected(xmpp_conn_t * const conn);
|
||||||
|
int xmpp_conn_is_disconnected(xmpp_conn_t * const conn);
|
||||||
|
|
||||||
int xmpp_connect_client(xmpp_conn_t * const conn,
|
int xmpp_connect_client(xmpp_conn_t * const conn,
|
||||||
const char * const altdomain,
|
const char * const altdomain,
|
||||||
|
|||||||
Reference in New Issue
Block a user