]> git.evergreen-ils.org Git - OpenSRF.git/blob - include/opensrf/transport_client.h
4d9dcc73c67543dcdc3673e5b9db4b7db22edbaf
[OpenSRF.git] / include / opensrf / transport_client.h
1 #ifndef TRANSPORT_CLIENT_H
2 #define TRANSPORT_CLIENT_H
3
4 /**
5         @file transport_client.h
6         @brief Header for implementation of transport_client.
7
8         The transport_client routines provide an interface for sending and receiving Jabber
9         messages, one at a time.
10 */
11
12 #include <time.h>
13 #include <opensrf/transport_session.h>
14 #include <opensrf/utils.h>
15 #include <opensrf/log.h>
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 struct message_list_struct;
22
23 /**
24         @brief A collection of members used for keeping track of transport_messages.
25
26         Among other things, this struct includes a queue of incoming messages, and
27         a Jabber ID for outgoing messages.
28 */
29 struct transport_client_struct {
30         transport_message* msg_q_head;   /**< Head of message queue */
31         transport_message* msg_q_tail;   /**< Tail of message queue */
32         transport_session* session;      /**< Manages lower-level message processing */
33         int error;                       /**< Boolean: true if an error has occurred */
34         char* host;                      /**< Domain name or IP address of the Jabber server */
35         char* xmpp_id;                   /**< Jabber ID used for outgoing messages */
36 };
37 typedef struct transport_client_struct transport_client;
38
39 transport_client* client_init( const char* server, int port, const char* unix_path, int component );
40
41 int client_connect( transport_client* client, 
42                 const char* username, const char* password, const char* resource,
43                 int connect_timeout, enum TRANSPORT_AUTH_TYPE auth_type );
44
45 int client_disconnect( transport_client* client );
46
47 int client_free( transport_client* client );
48
49 int client_send_message( transport_client* client, transport_message* msg );
50
51 int client_connected( const transport_client* client );
52
53 transport_message* client_recv( transport_client* client, int timeout );
54
55 int client_sock_fd( transport_client* client );
56
57 #ifdef __cplusplus
58 }
59 #endif
60
61 #endif