--- a/src/SocketHandler.h Thu Jul 28 02:45:11 2022 +0200
+++ b/src/SocketHandler.h Fri Jul 29 18:03:49 2022 +0200
@@ -50,15 +50,24 @@
std::string currentValue;
} currentRelation;
+ void configureSocket() {
+ if (socket) {
+ // already configured, reuse
+ } else {
+ std::vector<SocketOption> options;
+ for (auto o : configuration.options) options.push_back({convertor.to_bytes(o.name), convertor.to_bytes(o.value)});
+ const std::string connectionString = convertor.to_bytes(configuration.connectionString);
+ if (auto f = SocketFactory::find(connectionString)) socket = f->open(connectionString);
+ }
+ }
+
public:
SocketHandler(Configuration configuration) : configuration(configuration) {
- // TODO: do not throw exception from the constructor: Socket::open()
- // socket = std::make_shared<TCPSocket>(); // TODO: create a TCP, UDP… socket
- socket.reset(SocketFactory::find("tcp://TODO:connectionString")->open("tcp://TODO:connectionString2")); // TODO: connection string + check nullptr
}
void startRelation(relpipe::common::type::StringX name, std::vector<relpipe::reader::handlers::AttributeMetadata> attributes) override {
+ configureSocket();
currentRelation = CurrentRelation{name, attributes};
}