redboltz / mqtt_cpp

Boost Software License 1.0
441 stars 107 forks source link

Client sample out of main scope #975

Open codesian opened 1 year ago

codesian commented 1 year ago

Hi, a begginer here.

There is an example about client use out of main scope? How to store on a class member, something more generic than shot and close on main?

Thanks!

redboltz commented 1 year ago

See bench.cpp https://github.com/redboltz/mqtt_cpp/blob/27765791adaede2ce5340f81405ad6304387b12d/example/bench.cpp#L1054-L1070

It is a little tricky because mqtt_cpp supports various underlying layer without virtual function mechanism to support templates. So we need to use decltype() to get the type information.