33 #include <netinet/ip.h> 42 #include "amps/amps_generated.h" 44 #ifdef AMPS_CPP_COUNT_THREADS 48 size_t amps_get_thread_create_count(
void);
49 size_t amps_get_thread_join_count(
void);
50 size_t amps_get_thread_detach_count(
void);
58 #define AMPS_INVALID_SOCKET INVALID_SOCKET 60 #define AMPS_INVALID_SOCKET -1 66 #define AMPSDLL __declspec(dllexport) 68 #define AMPSDLL __declspec(dllimport) 73 #define AMPS_USLEEP(x) Sleep((DWORD)(x)/(DWORD)1000); 74 #define AMPS_YIELD() SwitchToThread() 75 #define AMPS_CURRENT_THREAD() GetCurrentThreadId() 76 typedef HANDLE AMPS_THREAD_T;
77 typedef DWORD AMPS_THREAD_ID;
78 typedef SOCKET AMPS_SOCKET;
79 typedef __int32 amps_int32_t;
80 typedef unsigned __int32 amps_uint32_t;
81 typedef __int64 amps_int64_t;
82 typedef unsigned __int64 amps_uint64_t;
85 #define AMPS_USLEEP(x) usleep((useconds_t)x) 86 #define AMPS_YIELD() sched_yield() 87 #define AMPS_CURRENT_THREAD() pthread_self() 88 typedef pthread_t AMPS_THREAD_T;
89 typedef pthread_t AMPS_THREAD_ID;
90 typedef int AMPS_SOCKET;
91 typedef int32_t amps_int32_t;
92 typedef uint32_t amps_uint32_t;
93 typedef int64_t amps_int64_t;
94 typedef uint64_t amps_uint64_t;
97 #if defined(_WIN32) || defined(__SSE_4_2__) 203 typedef char amps_char;
277 typedef void(*amps_predisconnect_handler)(
amps_handle, unsigned,
void*);
290 const amps_char* clientName);
304 const amps_char* clientName);
315 const amps_char* uri);
343 amps_char* errorMessageOut,
355 amps_handle message);
368 unsigned* version_out);
381 amps_handler messageHandler,
394 amps_predisconnect_handler predisconnectHandler,
407 amps_handler disconnectHandler,
487 const amps_char** value_ptr,
500 const amps_char* value,
513 const amps_char* value,
526 const amps_char* value);
547 const amps_char* value,
558 const amps_char* value,
568 const amps_char* value);
584 amps_char** value_ptr,
719 amps_tcps_get_socket(amps_handle transport);
732 AMPSDLL amps_uint64_t
796 AMPSDLL
void amps_noOpFn(
void*);
801 AMPSDLL
void amps_set_waiting_function(
void*);
802 AMPSDLL
void amps_invoke_waiting_function(
void);
803 AMPSDLL
void amps_set_remove_route_function(
void*);
804 AMPSDLL
void amps_invoke_remove_route_function(
void*);
805 AMPSDLL
void amps_set_copy_route_function(
void*);
806 AMPSDLL
void* amps_invoke_copy_route_function(
void*);
810 #if !defined(_AMPS_BUILD_C_CLIENT) && !defined(_AMPS_SKIP_AMPSPLUSPLUS) AMPSDLL void amps_ssl_free(void)
Frees OpenSSL context and shared library.
A connection error occurred.
Definition: amps.h:233
AMPSDLL void amps_client_set_disconnect_handler(amps_handle client, amps_handler disconnectHandler, void *userData)
Sets the disconnect handler function to be called when a disconnect occurs.
AMPSDLL amps_handle amps_message_create(amps_handle client)
Functions for creation and manipulation of AMPS messages.
AMPSDLL amps_result amps_client_set_thread_exit_callback(amps_handle client, amps_thread_exit_callback callback, void *userData)
Sets a user-supplied callback function for when a thread created for a connection is exiting...
AMPSDLL int amps_ssl_set_verify(int mode_)
Configures OpenSSL to validate the server's certificate when connecting.
The specified URI is invalid.
Definition: amps.h:261
AMPSDLL amps_result amps_client_set_name(amps_handle handle, const amps_char *clientName)
Sets the name on an amps client object.
AMPSDLL amps_handle amps_message_copy(amps_handle message)
Creates and returns a handle to a new AMPS message object that is a deep copy of the message passed i...
AMPSDLL amps_result amps_client_connect(amps_handle handle, const amps_char *uri)
Connects to the AMPS server specified in uri.
AMPSDLL void amps_client_disconnect(amps_handle handle)
Disconnects from the AMPS server, if connected.
AMPSDLL AMPS_SOCKET amps_client_get_socket(amps_handle client)
Returns the socket from the underlying transport in client, or NULL if no transport is associated wit...
A Secure Sockets Layer (SSL) error occurred.
Definition: amps.h:273
AMPSDLL amps_result amps_client_set_transport_filter_function(amps_handle client, amps_transport_filter_function filter, void *userData)
Sets a user-supplied callback function for filtering data before it is sent and after it is received...
AMPSDLL amps_uint64_t amps_message_get_field_uint64(amps_handle message, FieldId field)
Gets the unsigned 64-bit int value of a header field in an AMPS message.
AMPSDLL amps_result amps_client_set_idle_time(amps_handle client, int idleTime)
Sets an idle-time (milliseconds).
AMPSDLL unsigned long amps_message_get_field_long(amps_handle message, FieldId field)
Gets the long integer value of a header field in an AMPS message.
AMPSDLL void amps_message_set_field_value(amps_handle message, FieldId field, const amps_char *value, size_t length)
Sets the value of a header field in an AMPS message.
Success.
Definition: amps.h:221
The specified topic was invalid.
Definition: amps.h:237
void * amps_handle
Opaque handle type used to refer to objects in the AMPS api.
Definition: amps.h:211
AMPSDLL void amps_message_assign_data(amps_handle message, const amps_char *value, size_t length)
Assigns the data component of an AMPS message, without copying the value.
amps_result
Return values from amps_xxx functions.
Definition: amps.h:216
AMPSDLL amps_handle amps_client_create(const amps_char *clientName)
Functions for creation of an AMPS client.
void(* amps_transport_filter_function)(const unsigned char *, size_t, short, void *)
Prototype for a user-supplied callback function for filtering data before it is sent and after it is ...
Definition: amps.h:642
AMPSDLL size_t amps_client_get_error(amps_handle client, amps_char *errorMessageOut, size_t bufferSize)
Returns the last error set on this client.
AMPSDLL amps_result amps_client_send_with_version(amps_handle client, amps_handle message, unsigned *version_out)
Sends a message to the AMPS server.
AMPSDLL void amps_client_set_message_handler(amps_handle client, amps_handler messageHandler, void *userData)
Sets the message handler function for this client.
A memory error occurred.
Definition: amps.h:225
AMPSDLL void amps_message_set_data_nts(amps_handle message, const amps_char *value)
Sets the data component of an AMPS message.
AMPSDLL void amps_message_reset(amps_handle message)
Clears all fields and data in a message.
Core type, function, and class declarations for the AMPS C++ client.
The specified filter was invalid.
Definition: amps.h:241
An error with a command occurred.
Definition: amps.h:229
AMPSDLL void amps_message_get_field_value(amps_handle message, FieldId field, const amps_char **value_ptr, size_t *length_ptr)
Retrieves the value of a header field in an AMPS message.
AMPSDLL void * amps_tcps_get_SSL(amps_handle transport)
Retrieves the SSL object from the underlying TCPS transport.
AMPSDLL void amps_message_get_data(amps_handle message, amps_char **value_ptr, size_t *length_ptr)
Gets the data component of an AMPS message.
AMPSDLL AMPS_SOCKET amps_tcp_get_socket(amps_handle transport)
TRANSPORT-SPECIFIC APIS.
AMPSDLL void amps_message_destroy(amps_handle message)
Destroys and frees the memory associated with an AMPS message object.
The server could not be found, or it actively refused our connection.
Definition: amps.h:253
AMPSDLL void amps_message_assign_field_value(amps_handle message, FieldId field, const amps_char *value, size_t length)
Assigns the value of a header field in an AMPS message, without copying the value.
AMPSDLL void amps_message_set_data(amps_handle message, const amps_char *value, size_t length)
Sets the data component of an AMPS message.
AMPSDLL void amps_client_set_predisconnect_handler(amps_handle client, amps_predisconnect_handler predisconnectHandler, void *userData)
Sets the predisconnect handler function to be called when a disconnect occurs.
AMPSDLL amps_handle amps_client_get_transport(amps_handle client)
Returns a handle to the transport set in client, or NULL if no transport is associated with this tran...
AMPSDLL void amps_message_set_field_guid(amps_handle message, FieldId field)
Sets the value of a header field in an AMPS message to a new, globally unique identifier("GUID") ...
The usage of this function is invalid.
Definition: amps.h:269
AMPSDLL void amps_message_set_field_value_nts(amps_handle message, FieldId field, const amps_char *value)
Sets the value of a header field in an AMPS message from a null-terminated string.
AMPSDLL amps_result amps_client_send(amps_handle client, amps_handle message)
Sends a message to the AMPS server.
AMPSDLL amps_result amps_client_set_thread_created_callback(amps_handle client, amps_thread_created_callback callback, void *userData)
Sets a user-supplied callback function to allow thread attributes to set when a new thread is created...
amps_result(* amps_thread_exit_callback)(AMPS_THREAD_ID, void *)
Prototype for a user-supplied callback function when a thread created for a connection is exiting...
Definition: amps.h:692
amps_result(* amps_thread_created_callback)(AMPS_THREAD_T, void *)
Prototype for a user-supplied callback function to allow thread attributes to be set when a new threa...
Definition: amps.h:668
A stream error has occurred.
Definition: amps.h:257
The operation has not succeeded, but ought to be retried.
Definition: amps.h:245
AMPSDLL amps_result amps_client_set_read_timeout(amps_handle client, int readTimeout)
Sets a read timeout (seconds), in which if no message is received, the connection is presumed dead...
AMPSDLL const char * amps_ssl_get_error(void)
Returns the description of the last error from calling amps_ssl_init().
AMPSDLL int amps_ssl_init(const char *dllPath_)
Initializes SSL support in the AMPS Client.
AMPSDLL amps_result amps_client_attempt_reconnect(amps_handle client, unsigned version)
Manually invokes the user-supplied disconnect handler for this client.
AMPSDLL void amps_client_destroy(amps_handle handle)
Disconnects and destroys an AMPS client object.
AMPSDLL int amps_ssl_load_verify_locations(const char *caFile_, const char *caPath_)
Configures OpenSSL to use the specified locations for locating CA certificates.
The client and server are disconnected.
Definition: amps.h:249
The specified transport type is invalid.
Definition: amps.h:265