 |
helics
3.3.0
|
10 #include "TypedBrokerServer.hpp"
16 #if defined(HELICS_ENABLE_TCP_CORE) || defined(HELICS_ENABLE_UDP_CORE)
18 # include "gmlc/networking/AsioContextManager.h"
23 # ifdef HELICS_ENABLE_TCP_CORE
24 namespace gmlc::networking {
32 # ifdef HELICS_ENABLE_UDP_CORE
41 class AsioBrokerServer:
public TypedBrokerServer {
43 AsioBrokerServer() =
default;
44 explicit AsioBrokerServer(std::string_view server_name): name_(server_name) {}
47 const std::shared_ptr<TypedBrokerServer>& ptr)
override;
50 virtual void processArgs(std::string_view args)
override;
51 void enableTcpServer(
bool enabled) { tcp_enabled_ = enabled; }
52 void enableUdpServer(
bool enabled) { udp_enabled_ = enabled; }
56 # ifdef HELICS_ENABLE_TCP_CORE
57 std::shared_ptr<gmlc::networking::TcpServer> loadTCPserver(asio::io_context& ioctx);
58 static void loadTCPServerData(portData& pdata);
60 tcpDataReceive(
const std::shared_ptr<gmlc::networking::TcpConnection>& connection,
62 size_t bytes_received);
63 std::shared_ptr<gmlc::networking::TcpServer> tcpserver;
66 # ifdef HELICS_ENABLE_UDP_CORE
67 std::shared_ptr<udp::UdpServer> loadUDPserver(asio::io_context& ioctx);
68 static void loadUDPServerData(portData& pdata);
70 bool udpDataReceive(
const std::shared_ptr<udp::UdpServer>& server,
72 size_t bytes_received);
73 std::shared_ptr<udp::UdpServer> udpserver;
77 std::thread mainLoopThread;
78 std::mutex threadGuard;
80 const Json::Value* config_{
nullptr};
81 const std::string name_;
82 bool tcp_enabled_{
false};
83 bool udp_enabled_{
false};
96 void enableTcpServer(
bool ) {}
97 void enableUdpServer(
bool ) {}
100 const std::shared_ptr<TypedBrokerServer>& )
override
@ UDP
use UDP packets to send the data
Definition: Player.hpp:43
virtual void startServer(const Json::Value *, const std::shared_ptr< TypedBrokerServer > &) override
Definition: AsioBrokerServer.hpp:99
Definition: Tracer.hpp:26
Definition: AsioBrokerServer.hpp:92
static ActionMessage generateMessageResponse(const ActionMessage &rxcmd, portData &pdata, CoreType ctype)
Definition: TypedBrokerServer.cpp:65
Definition: application_api/BrokerApp.hpp:26
@ HELICS_CORE_TYPE_UDP
Definition: helics_enums.h:41
Definition: helicsCLI11.hpp:42
Definition: Source.hpp:64
void cleanupHelicsLibrary()
Definition: Federate.cpp:38
virtual void processArgs(std::string_view args)
Definition: TypedBrokerServer.cpp:99
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:186
@ TCP
use a generic TCP protocol message stream to send messages
virtual void stopServer() override
Definition: AsioBrokerServer.hpp:104
@ HELICS_CORE_TYPE_TCP
Definition: helics_enums.h:39
Definition: Recorder.hpp:27