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