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;
24 typedef struct transport_client_struct transport_client;
26 // ---------------------------------------------------------------------------
27 // Allocates and initializes a transport_client. This does no connecting
28 // The user must call client_free(client) when finished with the allocated
30 // if port > 0 => connect via TCP
31 // else if unix_path != NULL => connect via UNIX socket
32 // ---------------------------------------------------------------------------
33 transport_client* client_init( const char* server, int port, const char* unix_path, int component );
36 // ---------------------------------------------------------------------------
37 // Connects to the Jabber server with the provided information. Returns 1 on
38 // success, 0 otherwise.
39 // ---------------------------------------------------------------------------
40 int client_connect( transport_client* client,
41 const char* username, const char* password, const char* resource,
42 int connect_timeout, enum TRANSPORT_AUTH_TYPE auth_type );
45 int client_disconnect( transport_client* client );
47 // ---------------------------------------------------------------------------
48 // De-allocates memory associated with a transport_client object. Users
49 // must use this method when finished with a client object.
50 // ---------------------------------------------------------------------------
51 int client_free( transport_client* client );
53 // ---------------------------------------------------------------------------
54 // Sends the given message. The message must at least have the recipient
56 // ---------------------------------------------------------------------------
57 int client_send_message( transport_client* client, transport_message* msg );
59 // ---------------------------------------------------------------------------
60 // Returns 1 if this client is currently connected to the server, 0 otherwise
61 // ---------------------------------------------------------------------------
62 int client_connected( const transport_client* client );
64 // ---------------------------------------------------------------------------
65 // If there are any messages in the message list, the 'oldest' message is
66 // returned. If not, this function will wait at most 'timeout' seconds
67 // for a message to arrive. Specifying -1 means that this function will not
68 // return unless a message arrives.
69 // ---------------------------------------------------------------------------
70 transport_message* client_recv( transport_client* client, int timeout );