Pack a CTI message
Procedure
Step 1 | Allocate a continuous block of memory. |
Step 2 | Add the message header to the beginning of the memory block. Reserve a 4-byte place for the BodyLength field to fill in later when you accurately know the message body length (when you have added all the Body fields). Convert the 4-byte MessageTypeID to network-byte order and add it to the memory block after the reserved BodyLength field. |
Step 3 | Convert each of the fixed message fields, one by one, to network-byte order, if needed, and add them to the memory block in the appropriate order according to the MessageTypeID. |
Step 4 | Convert the floating data fields, one by one, if needed, to the network-byte order. Add the fields in the floating part of the message into the memory block without any gap between the fields. |
Step 5 | Repeat this process to pack the rest of the floating fields until the end of the message. |
Step 6 | Remember to convert the BodyLength bytes from host-byte order to network-byte order. Then update the BodyLength field in the message header part of the memory block after all the floating fields are added to accurately reflect the message body length. |