Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.

Commit c394ef5

Browse files
committed
Added New Message Types: They need standard responses and UnitTest
1 parent 5f9493c commit c394ef5

File tree

8 files changed

+578
-56
lines changed

8 files changed

+578
-56
lines changed

projects/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ add_subdirectory(unit_test)
4646
# Step 3: Global Doxygen configuration
4747
# you might need to tweak this if you have multiple doxy files
4848
###############################################################################
49-
option(BUILD_DOC "Build documentation" ON)
50-
49+
option(BUILD_DOC "Build documentation" OFF)
50+
if (BUILD_DOC)
5151
# check if Doxygen is installed
5252
find_package(Doxygen)
53+
find_package(LATEX)
54+
5355

5456
set(DOXYGEN_GENERATE_LATEX YES)
5557
set(DOXYGEN_PROJECT_BRIEF "An oepn source reference implementation of the SUSTAIN Networking protocol")
@@ -66,3 +68,4 @@ if (DOXYGEN_FOUND)
6668
else (DOXYGEN_FOUND)
6769
message("Doxygen need to be installed to generate the doxygen documentation")
6870
endif (DOXYGEN_FOUND)
71+
endif(BUILD_DOC)

projects/libpfc_net/cpp/Protocol.cpp

Lines changed: 394 additions & 13 deletions
Large diffs are not rendered by default.

projects/libpfc_net/cpp/net/Multicast_Sender.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ Multicast_Sender::Implementation::~Implementation()
7979
Error Multicast_Sender::Implementation::multicast_setup(const std::string& multicast_address, uint16_t port)
8080
{
8181
boost::system::error_code ec;
82-
const auto multicast_address = boost::asio::ip::make_address(multicast_address, ec);
82+
const auto boost_multicast_address = boost::asio::ip::make_address(multicast_address, ec);
8383
if (!ec) {
84-
endpoint = boost::asio::ip::udp::endpoint(multicast_address, port);
84+
endpoint = boost::asio::ip::udp::endpoint(boost_multicast_address, port);
8585
socket = boost::asio::ip::udp::socket(io_context, endpoint.protocol());
8686
} else {
8787
system_status = Error::Code::PFC_IP_PARSE_ERROR;

projects/libpfc_net/cpp/net/Service.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,21 @@ struct Service::Implementation {
3535
void announce_service_creation(std::ostream&);
3636
void handle_service_broadcaster_message(std::istream&);
3737

38-
std::function<void(pfc_service_announcment&)> service_broadcast_callback; //!<Callback function that is called each time a new service is announced
38+
std::function<void(pfc_service_announcement&)> service_broadcast_callback; //!<Callback function that is called each time a new service is announced
3939

40-
pfc_service_announcment service_config; //!<Struct containing details that will be broadcasted over mulicast so other services and clients can subscribe
40+
pfc_service_announcement service_config; //!<Struct containing details that will be broadcasted over mulicast so other services and clients can subscribe
4141
Config::protocol style; //!<Configuration Style of the service implmentation
4242

43-
Multicast_Sender multicast_announcment; //!<periodically announces itself to the network
44-
Multicast_Receiver multicast_broadcast_listiner; //!< Responds to the announcment of new services
43+
Multicast_Sender multicast_announcement; //!<periodically announces itself to the network
44+
Multicast_Receiver multicast_broadcast_listiner; //!< Responds to the announcement of new services
4545
pfc::Error server_status; //!< Current Error code of the system else Success()
4646
};
4747

4848
//!
4949
//! \param bind_address [IN] std::string -- The IP4/IP6 address the implmentation will bind to for multicast purposes
5050
//! \param multicast_address [IN] std::string -- The IP4/IP6 address the implmentation will broadcast. Port number is assumed by the specification
5151
Service::Implementation::Implementation(const std::string& bind_address, const std::string& multicast_address)
52-
: multicast_announcment(multicast_address, g_pfc_registry_reg_port)
52+
: multicast_announcement(multicast_address, g_pfc_registry_reg_port)
5353
, multicast_broadcast_listiner(bind_address, multicast_address, g_pfc_registry_announce_port)
5454
{
5555
}
@@ -58,10 +58,10 @@ Service::Implementation::Implementation(const std::string& bind_address, const s
5858
//! Derived class is responsible for shutting down the true service activty
5959
Service::Implementation::~Implementation()
6060
{
61-
multicast_announcment.stop();
61+
multicast_announcement.stop();
6262
multicast_broadcast_listiner.stop();
6363

64-
multicast_announcment.join();
64+
multicast_announcement.join();
6565
multicast_broadcast_listiner.join();
6666
}
6767
//-----------------------------------------------------------------------------
@@ -87,11 +87,11 @@ void Service::Implementation::announce_service_creation(std::ostream& os)
8787
//!
8888
void Service::Implementation::handle_service_broadcaster_message(std::istream& is)
8989
{
90-
pfc_service_announcment announcment;
91-
if (announcment.deserialize(is).is_ok()) {
92-
std::cout << "Registry Sent:" << announcment << "\n";
90+
pfc_service_announcement announcement;
91+
if (announcement.deserialize(is).is_ok()) {
92+
std::cout << "Registry Sent:" << announcement << "\n";
9393
if(service_broadcast_callback)
94-
{ service_broadcast_callback(announcment); }
94+
{ service_broadcast_callback(announcement); }
9595
}
9696
}
9797
//-----------------------------------------------------------------------------
@@ -103,7 +103,7 @@ void Service::Implementation::handle_service_broadcaster_message(std::istream& i
103103
Service::Service(const Config config, const std::string& multicast_bind_address, const std::string& registry_multicast_address)
104104
: _impl(std::make_unique<Implementation>(std::move(multicast_bind_address), std::move(registry_multicast_address)))
105105
{
106-
pfc_service_announcment service;
106+
pfc_service_announcement service;
107107
service._name = config.name;
108108
service._protacol = (config.style == Config::pub_sub) ? pfc_protocol::pub_sub : pfc_protocol::req_req;
109109
service._address = config.address.c_str();
@@ -133,27 +133,27 @@ void Service::start()
133133
{
134134
using namespace std::placeholders;
135135
auto& impl = *_impl;
136-
_impl->multicast_announcment.async_send(std::bind(&Implementation::announce_service_creation, _impl.get(), _1));
136+
_impl->multicast_announcement.async_send(std::bind(&Implementation::announce_service_creation, _impl.get(), _1));
137137
_impl->multicast_broadcast_listiner.async_receive(std::bind(&Implementation::handle_service_broadcaster_message, _impl.get(), _1));
138138
}
139139
//-----------------------------------------------------------------------------
140140
//! Runnable interface stops all multiservice activity and asyncronous threading.
141141
void Service::stop()
142142
{
143-
_impl->multicast_announcment.stop();
143+
_impl->multicast_announcement.stop();
144144
_impl->multicast_broadcast_listiner.stop();
145145
}
146146
//-----------------------------------------------------------------------------
147-
//! Blocking call that will not return until multicast_announcment and multicast_braodcast_listner have been
147+
//! Blocking call that will not return until multicast_announcement and multicast_braodcast_listner have been
148148
void Service::join()
149149
{
150-
_impl->multicast_announcment.join();
150+
_impl->multicast_announcement.join();
151151
_impl->multicast_broadcast_listiner.join();
152152
}
153153
//-----------------------------------------------------------------------------
154154
//! Sets the callback function that qill be executed once per each service broadcast. void(void)
155155
//! \param func [IN] stores a std::function to be executed as a callback
156-
void Service::set_service_announcment_callback(std::function<void(pfc_service_announcment&)> func)
156+
void Service::set_service_announcement_callback(std::function<void(pfc_service_announcement&)> func)
157157
{
158158
_impl->service_broadcast_callback = func;
159159
}

0 commit comments

Comments
 (0)