 |
helics
3.0.1
|
10 #include "TypedBrokerServer.hpp"
16 #if defined(HELICS_ENABLE_TCP_CORE) || defined(HELICS_ENABLE_UDP_CORE)
18 # include "helics/common/AsioContextManager.h"
24 # ifdef HELICS_ENABLE_TCP_CORE
30 # ifdef HELICS_ENABLE_UDP_CORE
39 class AsioBrokerServer:
public TypedBrokerServer {
41 AsioBrokerServer() =
default;
42 explicit AsioBrokerServer(std::string server_name): name_(std::move(server_name)) {}
44 virtual void startServer(
const Json::Value* val)
override;
47 virtual void processArgs(
const std::string& args)
override;
48 void enableTcpServer(
bool enabled) { tcp_enabled_ = enabled; }
49 void enableUdpServer(
bool enabled) { udp_enabled_ = enabled; }
53 # ifdef HELICS_ENABLE_TCP_CORE
54 std::shared_ptr<tcp::TcpServer> loadTCPserver(asio::io_context& ioctx);
55 static void loadTCPServerData(portData& pdata);
56 std::size_t tcpDataReceive(
const std::shared_ptr<tcp::TcpConnection>& connection,
58 size_t bytes_received);
59 std::shared_ptr<tcp::TcpServer> tcpserver;
62 # ifdef HELICS_ENABLE_UDP_CORE
63 std::shared_ptr<udp::UdpServer> loadUDPserver(asio::io_context& ioctx);
64 static void loadUDPServerData(portData& pdata);
66 bool udpDataReceive(
const std::shared_ptr<udp::UdpServer>& server,
68 size_t bytes_received);
69 std::shared_ptr<udp::UdpServer> udpserver;
73 std::thread mainLoopThread;
74 std::mutex threadGuard;
76 const Json::Value* config_{
nullptr};
77 const std::string name_;
78 bool tcp_enabled_{
false};
79 bool udp_enabled_{
false};
92 void enableTcpServer(
bool ) {}
93 void enableUdpServer(
bool ) {}
virtual void processArgs(const std::string &args)
Definition: TypedBrokerServer.cpp:99
@ UDP
use UDP packets to send the data
Definition: Player.hpp:42
static std::shared_ptr< AsioContextManager > getContextPointer(const std::string &contextName=std::string())
Definition: AsioContextManager.cpp:38
Definition: Tracer.hpp:25
Definition: AsioBrokerServer.hpp:88
static ActionMessage generateMessageResponse(const ActionMessage &rxcmd, portData &pdata, CoreType ctype)
Definition: TypedBrokerServer.cpp:65
Definition: application_api/BrokerApp.hpp:26
Definition: helicsCLI11.hpp:41
Definition: Source.hpp:60
virtual void startServer(const Json::Value *) override
Definition: AsioBrokerServer.hpp:95
void cleanupHelicsLibrary()
Definition: Federate.cpp:37
bool isProtocolCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:226
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
Definition: TypedBrokerServer.hpp:24
Definition: application_api/BrokerApp.hpp:172
@ TCP
use a generic TCP protocol message stream to send messages
virtual void stopServer() override
Definition: AsioBrokerServer.hpp:97
Definition: Recorder.hpp:26