| 1 | ## AWS C Event Stream |
| 2 | |
| 3 | C99 implementation of the vnd.amazon.event-stream content-type. Spec of event-stream: https://smithy.io/2.0/aws/amazon-eventstream.html#amazon-event-stream-specification. |
| 4 | |
| 5 | ## License |
| 6 | |
| 7 | This library is licensed under the Apache 2.0 License. |
| 8 | |
| 9 | ## Usage |
| 10 | |
| 11 | ### Building |
| 12 | |
| 13 | CMake 3.9+ is required to build. |
| 14 | |
| 15 | `<install-path>` must be an absolute path in the following instructions. |
| 16 | |
| 17 | #### Linux-Only Dependencies |
| 18 | |
| 19 | If you are building on Linux, you will need to build aws-lc and s2n-tls first. |
| 20 | |
| 21 | ``` |
| 22 | git clone [email protected]:awslabs/aws-lc.git |
| 23 | cmake -S aws-lc -B aws-lc/build -DCMAKE_INSTALL_PREFIX=<install-path> |
| 24 | cmake --build aws-lc/build --target install |
| 25 | |
| 26 | git clone [email protected]:aws/s2n-tls.git |
| 27 | cmake -S s2n-tls -B s2n-tls/build -DCMAKE_INSTALL_PREFIX=<install-path> -DCMAKE_PREFIX_PATH=<install-path> |
| 28 | cmake --build s2n-tls/build --target install |
| 29 | ``` |
| 30 | |
| 31 | #### Building aws-c-event-stream and Remaining Dependencies |
| 32 | |
| 33 | ``` |
| 34 | git clone [email protected]:awslabs/aws-c-common.git |
| 35 | cmake -S aws-c-common -B aws-c-common/build -DCMAKE_INSTALL_PREFIX=<install-path> |
| 36 | cmake --build aws-c-common/build --target install |
| 37 | |
| 38 | git clone [email protected]:awslabs/aws-checksums.git |
| 39 | cmake -S aws-checksums -B aws-checksums/build -DCMAKE_INSTALL_PREFIX=<install-path> -DCMAKE_PREFIX_PATH=<install-path> |
| 40 | cmake --build aws-checksums/build --target install |
| 41 | |
| 42 | git clone [email protected]:awslabs/aws-c-cal.git |
| 43 | cmake -S aws-c-cal -B aws-c-cal/build -DCMAKE_INSTALL_PREFIX=<install-path> -DCMAKE_PREFIX_PATH=<install-path> |
| 44 | cmake --build aws-c-cal/build --target install |
| 45 | |
| 46 | git clone [email protected]:awslabs/aws-c-io.git |
| 47 | cmake -S aws-c-io -B aws-c-io/build -DCMAKE_INSTALL_PREFIX=<install-path> -DCMAKE_PREFIX_PATH=<install-path> |
| 48 | cmake --build aws-c-io/build --target install |
| 49 | |
| 50 | git clone [email protected]:awslabs/aws-c-event-stream.git |
| 51 | cmake -S aws-c-event-stream -B aws-c-event-stream/build -DCMAKE_INSTALL_PREFIX=<install-path> -DCMAKE_PREFIX_PATH=<install-path> |
| 52 | cmake --build aws-c-event-stream/build --target install |
| 53 | ``` |
| 54 | |
| 55 | ## Encoding |
| 56 | |
| 57 | Event stream encoding provides bidirectional communication between a client and a server. |
| 58 | |
| 59 | Each message consists of two sections: the prelude and the data. The prelude consists of: |
| 60 | 1. The total byte length of the message |
| 61 | 2. The combined byte length of all headers |
| 62 | |
| 63 | The data section consists of: |
| 64 | 1. Headers |
| 65 | 2. Payload |
| 66 | |
| 67 | Each section ends with a 4-byte big-endian CRC32 checksum. The message checksum is for both the prelude section and the data section. |
| 68 | |
| 69 | Total message overhead, including the prelude and both checksums, is 16 bytes. |
| 70 | |
| 71 | The following diagram shows the components that make up a message and a header. There are multiple headers per message. |
| 72 | |
| 73 |  |