From 8fca7d6ea2d7e191d8b4201e3490bfd001813461 Mon Sep 17 00:00:00 2001 From: xengineering Date: Tue, 16 Aug 2022 08:11:38 +0200 Subject: Handle every xmpp_conn_event_t with debug message --- limox.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'limox.c') diff --git a/limox.c b/limox.c index 618c2ef..b0e74dd 100644 --- a/limox.c +++ b/limox.c @@ -37,18 +37,34 @@ static xmpp_sm_state_t* sm_state; static void conn_handler(xmpp_conn_t *conn, xmpp_conn_event_t status,int error, xmpp_stream_error_t *stream_error, void *userdata) { - if (status == XMPP_CONN_CONNECT) { - printf("DEBUG: connected\n"); - - // send initial presence - xmpp_stanza_t* presence; - presence = xmpp_presence_new(ctx); - xmpp_send(conn, presence); - xmpp_stanza_release(presence); - } else if (status == XMPP_CONN_DISCONNECT) { - printf("got XMPP_CONN_DISCONNECT\n"); - } else { - printf("Unhandled connection event!\n"); + switch (status) { + + case XMPP_CONN_CONNECT: + printf("DEBUG: Got XMPP_CONN_CONNECT\n"); + + // send initial presence + xmpp_stanza_t* presence; + presence = xmpp_presence_new(ctx); + xmpp_send(conn, presence); + xmpp_stanza_release(presence); + + break; + + case XMPP_CONN_RAW_CONNECT: + printf("DEBUG: Got XMPP_CONN_RAW_CONNECT\n"); + break; + + case XMPP_CONN_DISCONNECT: + printf("DEBUG: Got XMPP_CONN_DISCONNECT\n"); + break; + + case XMPP_CONN_FAIL: + printf("DEBUG: Got XMPP_CONN_FAIL\n"); + break; + + default: + printf("DEBUG: Got unknown connection status '%d'!\n", status); + exit(1); } } -- cgit v1.2.3-70-g09d2