]> git.evergreen-ils.org Git - OpenSRF.git/blob - include/opensrf/transport_client.h
In osrfStringArrayRemove(): fixed a bug whereby we would decrement
[OpenSRF.git] / include / opensrf / transport_client.h
1 #ifndef TRANSPORT_CLIENT_H
2 #define TRANSPORT_CLIENT_H
3
4 #include <time.h>
5 #include <opensrf/transport_session.h>
6 #include <opensrf/utils.h>
7 #include <opensrf/log.h>
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12
13 struct message_list_struct;
14
15 // ---------------------------------------------------------------------------
16 // Our client struct.  We manage a list of messages and a controlling session
17 // ---------------------------------------------------------------------------
18 struct transport_client_struct {
19         transport_message* msg_q_head;
20         transport_message* msg_q_tail;
21         transport_session* session;
22         int error;
23     char* host;
24     char* xmpp_id;
25 };
26 typedef struct transport_client_struct transport_client;
27
28 // ---------------------------------------------------------------------------
29 // Allocates and initializes a transport_client.  This does no connecting
30 // The user must call client_free(client) when finished with the allocated
31 // object.
32 // if port > 0 => connect via TCP
33 // else if unix_path != NULL => connect via UNIX socket
34 // ---------------------------------------------------------------------------
35 transport_client* client_init( const char* server, int port, const char* unix_path, int component );
36
37
38 // ---------------------------------------------------------------------------
39 // Connects to the Jabber server with the provided information. Returns 1 on
40 // success, 0 otherwise.
41 // ---------------------------------------------------------------------------
42 int client_connect( transport_client* client, 
43                 const char* username, const char* password, const char* resource,
44                 int connect_timeout, enum TRANSPORT_AUTH_TYPE auth_type );
45
46
47 int client_disconnect( transport_client* client );
48
49 // ---------------------------------------------------------------------------
50 // De-allocates memory associated with a transport_client object.  Users
51 // must use this method when finished with a client object.
52 // ---------------------------------------------------------------------------
53 int client_free( transport_client* client );
54
55 // ---------------------------------------------------------------------------
56 // Sends the given message.  The message must at least have the recipient
57 // field set.
58 // ---------------------------------------------------------------------------
59 int client_send_message( transport_client* client, transport_message* msg );
60
61 // ---------------------------------------------------------------------------
62 // Returns 1 if this client is currently connected to the server, 0 otherwise
63 // ---------------------------------------------------------------------------
64 int client_connected( const transport_client* client );
65
66 // ---------------------------------------------------------------------------
67 // If there are any messages in the message list, the 'oldest' message is
68 // returned.  If not, this function will wait at most 'timeout' seconds 
69 // for a message to arrive.  Specifying -1 means that this function will not
70 // return unless a message arrives.
71 // ---------------------------------------------------------------------------
72 transport_message* client_recv( transport_client* client, int timeout );
73
74 #ifdef __cplusplus
75 }
76 #endif
77
78 #endif