A small memory footprint AMQP implimentation

Dependents:   iothub_client_sample_amqp remote_monitoring simplesample_amqp

Revision:
38:7631b92cc772
Parent:
35:d0bed2404ee9
Child:
41:0e723f9cbd89
--- a/connection.c	Fri Dec 15 14:09:42 2017 -0800
+++ b/connection.c	Tue Jan 30 08:21:55 2018 -0800
@@ -102,13 +102,21 @@
     }
 }
 
+// This callback usage needs to be either verified and commented or integrated into 
+// the state machine.
+static void unchecked_on_send_complete(void* context, IO_SEND_RESULT send_result)
+{
+    (void)context;
+    (void)send_result;
+}
+
 static int send_header(CONNECTION_HANDLE connection)
 {
     int result;
 
     /* Codes_SRS_CONNECTION_01_093: [_ When the client opens a new socket connection to a server, it MUST send a protocol header with the client's preferred protocol version.] */
     /* Codes_SRS_CONNECTION_01_104: [Sending the protocol header shall be done by using xio_send.] */
-    if (xio_send(connection->io, amqp_header, sizeof(amqp_header), NULL, NULL) != 0)
+    if (xio_send(connection->io, amqp_header, sizeof(amqp_header), unchecked_on_send_complete, NULL) != 0)
     {
         /* Codes_SRS_CONNECTION_01_106: [When sending the protocol header fails, the connection shall be immediately closed.] */
         if (xio_close(connection->io, NULL, NULL) != 0)
@@ -238,7 +246,9 @@
 static void on_bytes_encoded(void* context, const unsigned char* bytes, size_t length, bool encode_complete)
 {
     CONNECTION_HANDLE connection = (CONNECTION_HANDLE)context;
-    if (xio_send(connection->io, bytes, length, encode_complete ? connection->on_send_complete : NULL, connection->on_send_complete_callback_context) != 0)
+    if (xio_send(connection->io, bytes, length, 
+        (encode_complete && connection->on_send_complete != NULL) ? connection->on_send_complete : unchecked_on_send_complete,
+        connection->on_send_complete_callback_context) != 0)
     {
         LogError("Cannot send encoded bytes");