diff options
| author | Joel Klinghed <the_jk@yahoo.com> | 2017-08-10 21:55:29 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@yahoo.com> | 2017-08-10 21:55:29 +0200 |
| commit | cc61af1e2c933f2178a5dc3e5a5599e74d380eb3 (patch) | |
| tree | 80e034aeb4f4511f7ddb3cc990fb6eb942a657ab /src/proxy.cc | |
| parent | e3f7ecc6bdf7bbd1ae7ec10c387e15743842db90 (diff) | |
Add duration to packages and tpp format
Diffstat (limited to 'src/proxy.cc')
| -rw-r--r-- | src/proxy.cc | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/proxy.cc b/src/proxy.cc index b1e5940..b8df00c 100644 --- a/src/proxy.cc +++ b/src/proxy.cc @@ -1929,30 +1929,35 @@ void ProxyImpl::send_attached_data(uint32_t id, void const* ptr, size_t size, } if (attached_.empty()) return; if (size == 0 && !last) return; - uint8_t data[10]; + uint8_t data[22]; data[0] = 'D'; data[1] = 'A'; data[2] = 'T'; write_u32(data + 5, id); + auto dur = looper_->now().time_since_epoch(); + auto sec = std::chrono::duration_cast<std::chrono::seconds>(dur); + write_u64(data + 10, sec.count()); + write_u32(data + 18, std::chrono::duration_cast<std::chrono::nanoseconds>( + dur - sec).count()); if (size == 0) { assert(last); assert(ptr == nullptr); write_u16(data + 3, 10); data[9] = 0; - send_attached(data, 10, nullptr, 0); + send_attached(data, 22, nullptr, 0); } else { - size_t max = 0xffff - 10; + size_t max = 0xffff - 22; auto p = reinterpret_cast<char const*>(ptr); data[9] = 1; while (size > max) { write_u16(data + 3, 0xffff); - send_attached(data, 10, p, max); + send_attached(data, 22, p, max); p += max; size -= max; } data[9] = last ? 0 : 1; - write_u16(data + 3, size + 10); - send_attached(data, 10, p, size); + write_u16(data + 3, size + 22); + send_attached(data, 22, p, size); } } |
