@@ -73,6 +73,8 @@ struct client::impl : public spl::enable_shared_from_this<client::impl>
73
73
std::map<udp::endpoint, int > reference_counts_by_endpoint_;
74
74
std::vector<char > buffer_;
75
75
76
+ int64_t time_ = 0 ;
77
+
76
78
std::mutex mutex_;
77
79
std::condition_variable cond_;
78
80
boost::optional<core::monitor::data_map_t > bundle_opt_;
@@ -112,10 +114,14 @@ struct client::impl : public spl::enable_shared_from_this<client::impl>
112
114
continue ;
113
115
}
114
116
115
- ::osc::OutboundPacketStream o (reinterpret_cast <char *>(buffer_.data ()),
116
- static_cast <unsigned long >(buffer_.size ()));
117
+ // TODO: Should use server clock.
118
+ time_++;
119
+
120
+ char buffer[8192 ];
117
121
118
- o << ::osc::BeginBundle ();
122
+ ::osc::OutboundPacketStream o (buffer_, 8192 );
123
+
124
+ o << ::osc::BeginBundle (time_);
119
125
120
126
for (auto & p : bundle) {
121
127
o << ::osc::BeginMessage (p.first .c_str ());
@@ -126,13 +132,30 @@ struct client::impl : public spl::enable_shared_from_this<client::impl>
126
132
}
127
133
128
134
o << ::osc::EndMessage;
135
+
136
+ if (o.Size () >= 1024 ) {
137
+ o << ::osc::EndBundle;
138
+
139
+ boost::system::error_code ec;
140
+ for (const auto & endpoint : endpoints) {
141
+ // TODO: async send
142
+ socket_.send_to (boost::asio::buffer (o.Data (), o.Size ()), endpoint, 0 , ec);
143
+ // TODO Handle error
144
+ }
145
+
146
+ o.Clear ();
147
+
148
+ o << ::osc::BeginBundle (time_);
149
+ }
129
150
}
130
151
131
152
o << ::osc::EndBundle;
132
153
133
154
boost::system::error_code ec;
134
155
for (const auto & endpoint : endpoints) {
156
+ // TODO: async send
135
157
socket_.send_to (boost::asio::buffer (o.Data (), o.Size ()), endpoint, 0 , ec);
158
+ // TODO Handle error
136
159
}
137
160
}
138
161
} catch (...) {
0 commit comments