Skip to content

Add RPC client server examples #5805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a642da5
Refs #23031: Add calculator generated types [Basic example]
Carlosespicur Apr 22, 2025
fe7f29e
Refs #23031: Add CLI Parser options
Carlosespicur Apr 22, 2025
0d3b3a2
Refs #23031: Add --connection-attempts option and parsing utilities t…
Carlosespicur Apr 23, 2025
2a67154
Refs #23031: Add ClientApp implementation [Basic Example]
Carlosespicur Apr 24, 2025
aec1e52
Refs #23031: Regenerate types [Basic Example]
Carlosespicur Apr 30, 2025
edafae2
Refs #23031: Fix invalid status code
Carlosespicur May 2, 2025
e495961
Refs #23031: Add ServerApp interface [Basic Example]
Carlosespicur May 2, 2025
19f9863
Refs #23031: Parse --thread-pool-size argument [Basic Example]
Carlosespicur May 5, 2025
492f7c8
Refs #23031: Fix errors in participant_ attributes
Carlosespicur May 5, 2025
ca0b70d
Refs #23031: Implement server operations [Basic Example]
Carlosespicur May 5, 2025
2ad1bdb
Refs #23031: Add server implementation [Basic Example]
Carlosespicur May 5, 2025
70af0ae
Refs #23031: Add files from basic example and generated types [Feed e…
Carlosespicur May 5, 2025
c824830
Refs #23031: Add Fibonacci sequence operation
Carlosespicur May 6, 2025
16eeefa
Refs #23031: Regenerate types
Carlosespicur May 6, 2025
af13169
Refs #23031: Add remaining operations to CLI
Carlosespicur May 6, 2025
1c5763e
Refs #23031: sum-all implementation
Carlosespicur May 6, 2025
c15d1f9
Refs #23031: Add accumulator implementation
Carlosespicur May 6, 2025
11dc0d6
Refs #23031: Add filter implementation
Carlosespicur May 7, 2025
5012782
Refs #23031: Fix typo
Carlosespicur May 7, 2025
5b1084c
Refs #23031: Regenerate types and set history to KEEP_ALL
Carlosespicur May 12, 2025
d6104b8
Refs #23031: Make private members protected
Carlosespicur May 20, 2025
8d15fa8
Refs #23031: Add timeouts to feed operations
Carlosespicur May 20, 2025
eea194b
Refs #23031: Move ping server logic to a separate method
Carlosespicur May 20, 2025
bbc8e42
Refs #23031: Configure client/server with default QoS
Carlosespicur May 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ add_subdirectory(cpp/discovery_server)
add_subdirectory(cpp/flow_control)
add_subdirectory(cpp/hello_world)
add_subdirectory(cpp/request_reply)
add_subdirectory(cpp/rpc_client_server_basic)
add_subdirectory(cpp/rpc_client_server_feed)
add_subdirectory(cpp/rtps)
add_subdirectory(cpp/static_edp_discovery)
add_subdirectory(cpp/topic_instances)
Expand Down
62 changes: 62 additions & 0 deletions examples/cpp/rpc_client_server_basic/Application.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright 2025 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @file Application.cpp
*
*/

#include "Application.hpp"

#include "CLIParser.hpp"
#include "ClientApp.hpp"
#include "ServerApp.hpp"

using namespace eprosima::fastdds::dds;

namespace eprosima {
namespace fastdds {
namespace examples {
namespace rpc_client_server {

//! Factory method to create a server or client
std::shared_ptr<Application> Application::make_app(
const CLIParser::config& config,
const std::string& service_name)
{
std::shared_ptr<Application> entity;
switch (config.entity)
{
case CLIParser::EntityKind::CLIENT:
{
entity = std::make_shared<ClientApp>(config, service_name);
break;
}
case CLIParser::EntityKind::SERVER:
{
entity = std::make_shared<ServerApp>(config, service_name);
break;
}
case CLIParser::EntityKind::UNDEFINED:
default:
throw std::runtime_error("Entity initialization failed");
break;
}
return entity;
}

} // namespace rpc_client_server
} // namespace examples
} // namespace fastdds
} // namespace eprosima
57 changes: 57 additions & 0 deletions examples/cpp/rpc_client_server_basic/Application.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @file Application.hpp
*
*/

#ifndef FASTDDS_EXAMPLES_CPP_RPC_CLIENT_SERVER_BASIC__APPLICATION_HPP
#define FASTDDS_EXAMPLES_CPP_RPC_CLIENT_SERVER_BASIC__APPLICATION_HPP

#include <memory>
#include <string>

#include "CLIParser.hpp"

namespace eprosima {
namespace fastdds {
namespace examples {
namespace rpc_client_server {

class Application
{
public:

//! Virtual destructor
virtual ~Application() = default;

//! Run application
virtual void run() = 0;

//! Trigger the end of execution
virtual void stop() = 0;

//! Factory method to create applications based on configuration
static std::shared_ptr<Application> make_app(
const CLIParser::config& config,
const std::string& service_name);
};

} // namespace rpc_client_server
} // namespace examples
} // namespace fastdds
} // namespace eprosima

#endif // FASTDDS_EXAMPLES_CPP_RPC_CLIENT_SERVER_BASIC__APPLICATION_HPP
Loading