1 #ifndef TRANSPORT_CLIENT_H
2 #define TRANSPORT_CLIENT_H
5 #include <opensrf/transport_session.h>
6 #include <opensrf/utils.h>
7 #include <opensrf/log.h>
13 struct message_list_struct;
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;
26 typedef struct transport_client_struct transport_client;
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
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 );
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 );
47 int client_disconnect( transport_client* client );
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 );
55 // ---------------------------------------------------------------------------
56 // Sends the given message. The message must at least have the recipient
58 // ---------------------------------------------------------------------------
59 int client_send_message( transport_client* client, transport_message* msg );
61 // ---------------------------------------------------------------------------
62 // Returns 1 if this client is currently connected to the server, 0 otherwise
63 // ---------------------------------------------------------------------------
64 int client_connected( const transport_client* client );
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 );