James Kuszmaul | 1ec7443 | 2020-07-30 20:26:45 -0700 | [diff] [blame] | 1 | #include "absl/types/span.h" |
Philipp Schrader | 790cb54 | 2023-07-05 21:06:52 -0700 | [diff] [blame] | 2 | |
Alex Perry | 5f474f2 | 2020-02-01 12:14:24 -0800 | [diff] [blame] | 3 | #include "aos/events/event_loop.h" |
James Kuszmaul | 1ec7443 | 2020-07-30 20:26:45 -0700 | [diff] [blame] | 4 | #include "aos/flatbuffers.h" |
Austin Schuh | 60e7794 | 2022-05-16 17:48:24 -0700 | [diff] [blame] | 5 | #include "aos/network/web_proxy_generated.h" |
Alex Perry | 5f474f2 | 2020-02-01 12:14:24 -0800 | [diff] [blame] | 6 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame] | 7 | namespace aos::web_proxy { |
Alex Perry | 5f474f2 | 2020-02-01 12:14:24 -0800 | [diff] [blame] | 8 | |
| 9 | int GetPacketCount(const Context &context); |
| 10 | |
Austin Schuh | 52e5e3a | 2021-04-24 22:30:02 -0700 | [diff] [blame] | 11 | // Packs a message embedded in context into a MessageHeader on fbb. Handles |
| 12 | // multipart messages by use of the packet_index. |
Alex Perry | 5f474f2 | 2020-02-01 12:14:24 -0800 | [diff] [blame] | 13 | flatbuffers::Offset<MessageHeader> PackMessage( |
| 14 | flatbuffers::FlatBufferBuilder *fbb, const Context &context, |
| 15 | int channel_index, int packet_index); |
| 16 | |
Austin Schuh | d16ef44 | 2021-04-25 14:44:42 -0700 | [diff] [blame] | 17 | // Returns the size that the overall packed message packed by PackMessage will |
| 18 | // be for the provided packet index. |
| 19 | size_t PackedMessageSize(const Context &context, int packet_index); |
| 20 | |
James Kuszmaul | 1ec7443 | 2020-07-30 20:26:45 -0700 | [diff] [blame] | 21 | // Packs the provided raw data into a series of MessageHeader's of the |
| 22 | // appropriate length. |
| 23 | std::vector<FlatbufferDetachedBuffer<MessageHeader>> PackBuffer( |
| 24 | absl::Span<const uint8_t> span); |
Alex Perry | 5f474f2 | 2020-02-01 12:14:24 -0800 | [diff] [blame] | 25 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame] | 26 | } // namespace aos::web_proxy |