di9it / msghub Goto Github PK
View Code? Open in Web Editor NEWLightweight publisher/subscriber C++ library based on boost asio
Lightweight publisher/subscriber C++ library based on boost asio
see title
Hi,
I am trying to create a pub/sub model using BoostAsio library with the help of your code.
I was able to establish a connection between the publisher and subscriber but the data is neither [published nor subscribe.
Could you please help me with the issue.
Thanks & Regards
Rakshita Parihar
Even on a publish-only channel there will be an extant async_read via hubconnection.
On publishers there will be an accept loop.
Both need cancelling.
There are many warnings (with -Wall -Wextra -pedantic). Some of these are already bugs (leading to immediate segfaults), some of them simply invite bugs. Others may prevent correct compilation on standard conforming compilers.
|| [ 14%] Building CXX object CMakeFiles/client.dir/msghub/src/hubclient.cpp.o
|| In file included from /home/sehe/Projects/stackoverflow/msghub/src/hubclient.h:6,
msghub/src/hubmessage.h|31 col 3| warning: ISO C++ prohibits anonymous structs [-Wpedantic]
|| 31 | {
|| | ^
|| [ 21%] Building CXX object CMakeFiles/client.dir/msghub/src/hubconnection.cpp.o
|| In file included from /home/sehe/Projects/stackoverflow/msghub/src/hubconnection.h:5,
msghub/src/hubmessage.h|31 col 3| warning: ISO C++ prohibits anonymous structs [-Wpedantic]
|| 31 | {
|| | ^
|| In file included from /home/sehe/Projects/stackoverflow/msghub/src/hubconnection.cpp:1:
|| /home/sehe/Projects/stackoverflow/msghub/src/hubconnection.h: In constructor ‘hubconnection::hubconnection(boost::asio::io_service&, hub&)’:
msghub/src/hubconnection.h|45 col 18| warning: ‘hubconnection::socket_’ will be initialized after [-Wreorder]
|| 45 | tcp::socket socket_;
|| | ^~~~~~~
msghub/src/hubconnection.h|43 col 12| warning: ‘hub& hubconnection::courier_’ [-Wreorder]
|| 43 | hub& courier_;
|| | ^~~~~~~~
msghub/src/hubconnection.cpp|24 col 1| warning: when initialized here [-Wreorder]
|| 24 | hubconnection::hubconnection(boost::asio::io_service& io_service, hub& courier)
|| | ^~~~~~~~~~~~~
|| [ 28%] Building CXX object CMakeFiles/client.dir/msghub/src/hubmessage.cpp.o
|| In file included from /home/sehe/Projects/stackoverflow/msghub/src/hubmessage.cpp:1:
msghub/src/hubmessage.h|31 col 3| warning: ISO C++ prohibits anonymous structs [-Wpedantic]
|| 31 | {
|| | ^
|| [ 35%] Building CXX object CMakeFiles/client.dir/msghub/src/msghub.cpp.o
|| In file included from /home/sehe/Projects/stackoverflow/msghub/src/hubconnection.h:5,
msghub/src/hubmessage.h|31 col 3| warning: ISO C++ prohibits anonymous structs [-Wpedantic]
|| 31 | {
|| | ^
|| [ 42%] Building CXX object CMakeFiles/client.dir/msghub/src/msghub_impl.cpp.o
|| In file included from /home/sehe/Projects/stackoverflow/msghub/src/hubconnection.h:5,
msghub/src/hubmessage.h|31 col 3| warning: ISO C++ prohibits anonymous structs [-Wpedantic]
|| 31 | {
|| | ^
|| In file included from /home/sehe/Projects/stackoverflow/msghub/src/msghub_impl.cpp:1:
|| /home/sehe/Projects/stackoverflow/msghub/src/msghub_impl.h: In constructor ‘msghub_impl::msghub_impl(boost::asio::io_service&)’:
msghub/src/msghub_impl.h|47 col 35| warning: ‘msghub_impl::publisher_’ will be initialized after [-Wreorder]
|| 47 | boost::shared_ptr<hubconnection> publisher_;
|| | ^~~~~~~~~~
msghub/src/msghub_impl.h|45 col 16| warning: ‘boost::asio::ip::tcp::acceptor msghub_impl::acceptor_’ [-Wreorder]
|| 45 | tcp::acceptor acceptor_;
|| | ^~~~~~~~~
msghub/src/msghub_impl.cpp|46 col 1| warning: when initialized here [-Wreorder]
|| 46 | msghub_impl::msghub_impl(boost::asio::io_service& io_service)
|| | ^~~~~~~~~~~
|| In file included from /home/sehe/Projects/stackoverflow/msghub/src/msghub_impl.cpp:1:
msghub/src/msghub_impl.h|45 col 16| warning: ‘msghub_impl::acceptor_’ will be initialized after [-Wreorder]
|| 45 | tcp::acceptor acceptor_;
|| | ^~~~~~~~~
msghub/src/msghub_impl.h|44 col 27| warning: ‘boost::asio::io_service& msghub_impl::io_service_’ [-Wreorder]
|| 44 | boost::asio::io_service& io_service_;
|| | ^~~~~~~~~~~
msghub/src/msghub_impl.cpp|46 col 1| warning: when initialized here [-Wreorder]
|| 46 | msghub_impl::msghub_impl(boost::asio::io_service& io_service)
|| | ^~~~~~~~~~~
|| In file included from /home/sehe/Projects/stackoverflow/msghub/src/msghub_impl.cpp:1:
msghub/src/msghub_impl.h|44 col 27| warning: ‘msghub_impl::io_service_’ will be initialized after [-Wreorder]
|| 44 | boost::asio::io_service& io_service_;
|| | ^~~~~~~~~~~
msghub/src/msghub_impl.h|42 col 8| warning: ‘bool msghub_impl::initok_’ [-Wreorder]
|| 42 | bool initok_;
|| | ^~~~~~~
msghub/src/msghub_impl.cpp|46 col 1| warning: when initialized here [-Wreorder]
|| 46 | msghub_impl::msghub_impl(boost::asio::io_service& io_service)
|| | ^~~~~~~~~~~
|| /home/sehe/Projects/stackoverflow/msghub/src/msghub_impl.cpp: In member function ‘virtual void msghub_impl::deliver(boost::shared_ptr<hubconnection>, hubmessage&)’:
msghub/src/msghub_impl.cpp|203 col 60| warning: unused parameter ‘publisher’ [-Wunused-parameter]
|| 203 | void msghub_impl::deliver(boost::shared_ptr<hubconnection> publisher, hubmessage& msg)
|| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
|| /home/sehe/Projects/stackoverflow/msghub/src/msghub_impl.cpp: In member function ‘void msghub_impl::handle_accept(boost::shared_ptr<hubclient>, const boost::system::error_code&)’:
msghub/src/msghub_impl.cpp|233 col 7| warning: unused variable ‘e’ [-Wunused-variable]
|| 233 | int e = error.value();
|| | ^
|| [ 50%] Linking CXX executable client
|| [ 50%] Built target client
|| [ 57%] Building CXX object CMakeFiles/server.dir/test.cpp.o
|| [ 64%] Building CXX object CMakeFiles/server.dir/msghub/src/hubclient.cpp.o
|| In file included from /home/sehe/Projects/stackoverflow/msghub/src/hubclient.h:6,
msghub/src/hubmessage.h|31 col 3| warning: ISO C++ prohibits anonymous structs [-Wpedantic]
|| 31 | {
|| | ^
|| [ 71%] Building CXX object CMakeFiles/server.dir/msghub/src/hubconnection.cpp.o
|| In file included from /home/sehe/Projects/stackoverflow/msghub/src/hubconnection.h:5,
msghub/src/hubmessage.h|31 col 3| warning: ISO C++ prohibits anonymous structs [-Wpedantic]
|| 31 | {
|| | ^
|| In file included from /home/sehe/Projects/stackoverflow/msghub/src/hubconnection.cpp:1:
|| /home/sehe/Projects/stackoverflow/msghub/src/hubconnection.h: In constructor ‘hubconnection::hubconnection(boost::asio::io_service&, hub&)’:
msghub/src/hubconnection.h|45 col 18| warning: ‘hubconnection::socket_’ will be initialized after [-Wreorder]
|| 45 | tcp::socket socket_;
|| | ^~~~~~~
msghub/src/hubconnection.h|43 col 12| warning: ‘hub& hubconnection::courier_’ [-Wreorder]
|| 43 | hub& courier_;
|| | ^~~~~~~~
msghub/src/hubconnection.cpp|24 col 1| warning: when initialized here [-Wreorder]
|| 24 | hubconnection::hubconnection(boost::asio::io_service& io_service, hub& courier)
|| | ^~~~~~~~~~~~~
|| [ 78%] Building CXX object CMakeFiles/server.dir/msghub/src/hubmessage.cpp.o
|| In file included from /home/sehe/Projects/stackoverflow/msghub/src/hubmessage.cpp:1:
msghub/src/hubmessage.h|31 col 3| warning: ISO C++ prohibits anonymous structs [-Wpedantic]
|| 31 | {
|| | ^
|| [ 85%] Building CXX object CMakeFiles/server.dir/msghub/src/msghub.cpp.o
|| In file included from /home/sehe/Projects/stackoverflow/msghub/src/hubconnection.h:5,
msghub/src/hubmessage.h|31 col 3| warning: ISO C++ prohibits anonymous structs [-Wpedantic]
|| 31 | {
|| | ^
|| [ 92%] Building CXX object CMakeFiles/server.dir/msghub/src/msghub_impl.cpp.o
|| In file included from /home/sehe/Projects/stackoverflow/msghub/src/hubconnection.h:5,
msghub/src/hubmessage.h|31 col 3| warning: ISO C++ prohibits anonymous structs [-Wpedantic]
|| 31 | {
|| | ^
|| In file included from /home/sehe/Projects/stackoverflow/msghub/src/msghub_impl.cpp:1:
|| /home/sehe/Projects/stackoverflow/msghub/src/msghub_impl.h: In constructor ‘msghub_impl::msghub_impl(boost::asio::io_service&)’:
msghub/src/msghub_impl.h|47 col 35| warning: ‘msghub_impl::publisher_’ will be initialized after [-Wreorder]
|| 47 | boost::shared_ptr<hubconnection> publisher_;
|| | ^~~~~~~~~~
msghub/src/msghub_impl.h|45 col 16| warning: ‘boost::asio::ip::tcp::acceptor msghub_impl::acceptor_’ [-Wreorder]
|| 45 | tcp::acceptor acceptor_;
|| | ^~~~~~~~~
msghub/src/msghub_impl.cpp|46 col 1| warning: when initialized here [-Wreorder]
|| 46 | msghub_impl::msghub_impl(boost::asio::io_service& io_service)
|| | ^~~~~~~~~~~
|| In file included from /home/sehe/Projects/stackoverflow/msghub/src/msghub_impl.cpp:1:
msghub/src/msghub_impl.h|45 col 16| warning: ‘msghub_impl::acceptor_’ will be initialized after [-Wreorder]
|| 45 | tcp::acceptor acceptor_;
|| | ^~~~~~~~~
msghub/src/msghub_impl.h|44 col 27| warning: ‘boost::asio::io_service& msghub_impl::io_service_’ [-Wreorder]
|| 44 | boost::asio::io_service& io_service_;
|| | ^~~~~~~~~~~
msghub/src/msghub_impl.cpp|46 col 1| warning: when initialized here [-Wreorder]
|| 46 | msghub_impl::msghub_impl(boost::asio::io_service& io_service)
|| | ^~~~~~~~~~~
|| In file included from /home/sehe/Projects/stackoverflow/msghub/src/msghub_impl.cpp:1:
msghub/src/msghub_impl.h|44 col 27| warning: ‘msghub_impl::io_service_’ will be initialized after [-Wreorder]
|| 44 | boost::asio::io_service& io_service_;
|| | ^~~~~~~~~~~
msghub/src/msghub_impl.h|42 col 8| warning: ‘bool msghub_impl::initok_’ [-Wreorder]
|| 42 | bool initok_;
|| | ^~~~~~~
msghub/src/msghub_impl.cpp|46 col 1| warning: when initialized here [-Wreorder]
|| 46 | msghub_impl::msghub_impl(boost::asio::io_service& io_service)
|| | ^~~~~~~~~~~
|| /home/sehe/Projects/stackoverflow/msghub/src/msghub_impl.cpp: In member function ‘virtual void msghub_impl::deliver(boost::shared_ptr<hubconnection>, hubmessage&)’:
msghub/src/msghub_impl.cpp|203 col 60| warning: unused parameter ‘publisher’ [-Wunused-parameter]
|| 203 | void msghub_impl::deliver(boost::shared_ptr<hubconnection> publisher, hubmessage& msg)
|| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
|| /home/sehe/Projects/stackoverflow/msghub/src/msghub_impl.cpp: In member function ‘void msghub_impl::handle_accept(boost::shared_ptr<hubclient>, const boost::system::error_code&)’:
msghub/src/msghub_impl.cpp|233 col 7| warning: unused variable ‘e’ [-Wunused-variable]
|| 233 | int e = error.value();
|| | ^
|| [100%] Linking CXX executable server
|| [100%] Built target server
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.