File tree 1 file changed +6
-4
lines changed
LibCarla/source/test/common
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -293,13 +293,15 @@ TEST(streaming, stream_outlives_server) {
293
293
std::atomic_store_explicit (&stream, s, std::memory_order_relaxed);
294
294
}
295
295
std::atomic_size_t messages_received{0u };
296
- {
296
+ {// 创建一个Client实例
297
297
Client c;
298
+ // 以异步方式启动客户端,参数2u同样可能涉及相关运行配置(和服务器端类似,取决于Client类实现)
298
299
c.AsyncRun (2u );
300
+ // 客户端进行订阅操作,传入从stream智能指针获取的token(标识)以及一个lambda表达式作为回调函数
299
301
c.Subscribe (stream->token (), [&](auto buffer) {
300
- const std::string result = as_string (buffer);
301
- ASSERT_EQ (result, message);
302
- ++messages_received;
302
+ const std::string result = as_string (buffer);// 将接收到的buffer转换为字符串类型,as_string函数应该是自定义的转换函数
303
+ ASSERT_EQ (result, message);// 使用断言验证转换后的结果是否和期望的message相等,message应该是外部定义的期望消息内容
304
+ ++messages_received;// 如果消息验证通过,将统计接收消息数量的变量messages_received自增1
303
305
});
304
306
std::this_thread::sleep_for (20ms);
305
307
} // client dies here.
You can’t perform that action at this time.
0 commit comments