JabberWerxC  2015.1.1
client.h
Go to the documentation of this file.
1 
13 #ifndef JABBERWERX_CLIENT_H
14 #define JABBERWERX_CLIENT_H
15 
16 #include "jid.h"
17 #include "tracker.h"
18 #include "stream.h"
19 #include "util/workq.h"
20 
21 
26 #define JW_CLIENT_CONFIG_USERJID "userjid"
27 
31 #define JW_CLIENT_CONFIG_USERPW "userpassword"
32 
37 #define JW_CLIENT_CONFIG_STREAM_TYPE "streamtype"
38 
43 #define JW_CLIENT_CONFIG_JID_CONTEXT "jidcontext"
44 
49 #define JW_CLIENT_CONFIG_SM_ENABLED "sm_enabled"
50 
56 #define JW_CLIENT_CONFIG_SM_RESUME_ENABLED "sm_resume_enabled"
57 
65 #define JW_CLIENT_CONFIG_SM_RESUME_TIMEOUT_SECONDS "sm_resume_timeout"
66 
78 #define JW_CLIENT_CONFIG_SM_ACK_REQUEST_THRESHOLD "sm_ack_request_threshold"
79 
99 #define JW_CLIENT_CONFIG_SM_ACK_REQUEST_THRESHOLD_SECONDS \
100  "sm_ack_request_threshold_seconds"
101 
121 #define JW_CLIENT_CONFIG_RECONNECT_BASE_COUNTDOWN "client_reconnect_countdown"
122 
128 #define JW_CLIENT_CONFIG_SASL_FACTORY "client_sasl_factory"
129 
133 #define JW_CLIENT_CONFIG_STREAM_TYPE_SOCKET "socket"
134 
137 #define JW_CLIENT_CONFIG_STREAM_TYPE_BOSH "bosh"
138 
143 #define JW_CLIENT_EVENT_STATUSCHANGED "clientStatusChanged"
144 
148 #define JW_CLIENT_EVENT_CONNECTED "clientConnected"
149 
153 #define JW_CLIENT_EVENT_DISCONNECTED "clientDisconnected"
154 
158 #define JW_CLIENT_EVENT_SESSION_PAUSED "clientSessionPaused"
159 
163 #define JW_CLIENT_EVENT_SESSION_RESUMED "clientSessionResumed"
164 
168 #define JW_CLIENT_EVENT_DESTROYED "clientDestroyed"
169 
174 #define JW_CLIENT_EVENT_BEFORE_IQ_RECEIVED "beforeIqReceived"
175 
179 #define JW_CLIENT_EVENT_IQ_RECEIVED "iqReceived"
180 
184 #define JW_CLIENT_EVENT_AFTER_IQ_RECEIVED "afterIqReceived"
185 
190 #define JW_CLIENT_EVENT_BEFORE_IQ_SENT "beforeIqSent"
191 
195 #define JW_CLIENT_EVENT_IQ_SENT "iqSent"
196 
201 #define JW_CLIENT_EVENT_BEFORE_PRESENCE_RECEIVED "beforePresenceReceived"
202 
206 #define JW_CLIENT_EVENT_PRESENCE_RECEIVED "presenceReceived"
207 
211 #define JW_CLIENT_EVENT_AFTER_PRESENCE_RECEIVED "afterPresenceReceived"
212 
217 #define JW_CLIENT_EVENT_BEFORE_PRESENCE_SENT "beforePresenceSent"
218 
222 #define JW_CLIENT_EVENT_PRESENCE_SENT "presenceSent"
223 
228 #define JW_CLIENT_EVENT_BEFORE_MESSAGE_RECEIVED "beforeMessageReceived"
229 
233 #define JW_CLIENT_EVENT_MESSAGE_RECEIVED "messageReceived"
234 
238 #define JW_CLIENT_EVENT_AFTER_MESSAGE_RECEIVED "afterMessageReceived"
239 
244 #define JW_CLIENT_EVENT_BEFORE_MESSAGE_SENT "beforeMessageSent"
245 
249 #define JW_CLIENT_EVENT_MESSAGE_SENT "messageSent"
250 
255 #define JW_CLIENT_EVENT_RECONNECT_STATUSCHANGED "reconnectStatusChanged"
256 
257 
261 typedef enum
262 {
263  JW_CLIENT_DISCONNECTED = 0,
264  JW_CLIENT_CONNECTING,
265  JW_CLIENT_CONNECTED,
266  JW_CLIENT_DISCONNECTING
268 
283 typedef enum
284 {
285  JW_CLIENT_RECONNECT_CANCELED = 0, // reconnect can not occur
286  JW_CLIENT_RECONNECT_PENDING, // reconnect attempt when possible
287  JW_CLIENT_RECONNECT_STARTING // connection is being attempted
289 
290 
292 typedef struct _jw_client jw_client;
293 
295 typedef struct _jw_client_status jw_client_status;
296 
298 typedef struct _jw_client_reconnect_status jw_client_reconnect_status;
299 
300 
301 #ifdef __cplusplus
302 extern "C"
303 {
304 #endif
305 
321  jw_client **client,
322  jw_err *err);
323 
338 
403  jw_htable *config,
404  jw_err *err);
405 
425  jw_errcode disconnect_reason);
426 
435 
443 JABBERWERX_API struct event_base* jw_client_get_selector(jw_client *client);
444 
453 
469 
485 
495 
510 
524  const char *name);
525 
537  jw_client_status *status);
538 
550  jw_client_status *status);
551 
563  jw_client_status *status);
564 
581 
598 
614 JABBERWERX_API uint32_t
616 
631 JABBERWERX_API uint32_t
633 
660  jw_dom_node *stanza,
661  jw_err *err);
662 
698  jw_dom_node *iq,
700  void *user_data,
701  uint32_t timeout_sec,
702  jw_err *err);
703 
704 #ifdef __cplusplus
705 }
706 #endif
707 
708 #endif /* JABBERWERX_CLIENT_H */
JABBERWERX_API bool jw_client_is_reconnect_pending(jw_client *client)
JABBERWERX_API void jw_client_destroy(jw_client *client)
#define JABBERWERX_API
Definition: basics.h:32
jw_errcode
Definition: basics.h:122
struct _jw_client_reconnect_status jw_client_reconnect_status
Definition: client.h:298
Functions and data structures for JIDs.
JABBERWERX_API jw_client_statustype jw_client_get_status(jw_client *client)
JABBERWERX_API jw_jid * jw_client_get_jid(jw_client *client)
JABBERWERX_API jw_dom_node * jw_client_status_get_error(jw_client_status *status)
struct _jw_dom_node jw_dom_node
Definition: dom.h:46
JABBERWERX_API jw_client_reconnect_statustype jw_client_reconnect_get_status(jw_client_reconnect_status *status)
Functions and data structures for tracking IQs and XDBs.
JABBERWERX_API bool jw_client_track_iq(jw_client *client, jw_dom_node *iq, jw_tracker_cb_func cb, void *user_data, uint32_t timeout_sec, jw_err *err)
struct _jw_client jw_client
Definition: client.h:292
Functions and data structures for Streams of XML data over a data transport, such as a TCP stream...
JABBERWERX_API void jw_client_disconnect(jw_client *client, jw_errcode disconnect_reason)
JABBERWERX_API bool jw_client_send_stanza(jw_client *client, jw_dom_node *stanza, jw_err *err)
JABBERWERX_API jw_htable * jw_client_get_config(jw_client *client)
void(* jw_tracker_cb_func)(jw_dom_node *result, void *arg)
Definition: tracker.h:38
JABBERWERX_API jw_client_statustype jw_client_status_get_previous(jw_client_status *status)
jw_client_statustype
Definition: client.h:261
struct jw_workq_t jw_workq
Definition: workq.h:30
struct _jw_client_status jw_client_status
Definition: client.h:295
JABBERWERX_API bool jw_client_connect(jw_client *client, jw_htable *config, jw_err *err)
JABBERWERX_API uint32_t jw_client_reconnect_get_countdown(jw_client_reconnect_status *status)
This file contains JabberWerxC Work Queue types and functions.
struct _jw_htable jw_htable
Definition: htable.h:27
Definition: basics.h:157
jw_client_reconnect_statustype
Definition: client.h:283
JABBERWERX_API bool jw_client_status_is_reconnect(jw_client_status *status)
JABBERWERX_API bool jw_client_is_connected(jw_client *client)
JABBERWERX_API struct event_base * jw_client_get_selector(jw_client *client)
JABBERWERX_API jw_client_statustype jw_client_status_get_next(jw_client_status *status)
struct _jw_jid_int jw_jid
Definition: jid.h:37
JABBERWERX_API bool jw_client_create(jw_workq *workq, jw_client **client, jw_err *err)
JABBERWERX_API uint32_t jw_client_reconnect_get_attempts(jw_client_reconnect_status *status)
JABBERWERX_API jw_workq * jw_client_get_workq(jw_client *client)
JABBERWERX_API jw_event * jw_client_event(jw_client *client, const char *name)
struct _jw_event_t jw_event
Definition: eventing.h:39