--- a/src/SocketCommand.cpp Sun Aug 07 10:45:05 2022 +0200
+++ b/src/SocketCommand.cpp Sun Aug 21 00:16:50 2022 +0200
@@ -47,21 +47,31 @@
void SocketCommand::process(std::shared_ptr<writer::RelationalWriter> writer, Configuration& configuration) {
vector<AttributeMetadata> metadata;
- std::shared_ptr<Socket> socket = std::make_shared<Socket>(); // TODO: create a TCP, UDP… socket
+ std::vector<SocketOption> options;
+ for (auto o : configuration.options) options.push_back({convertor.to_bytes(o.name), convertor.to_bytes(o.value)});
+ std::shared_ptr<Socket> socket = SocketFactory::find(options)->open(options);
writer->startRelation(configuration.relation,{
- {L"queue", TypeId::STRING},
+ {L"host", TypeId::STRING},
+ {L"port", TypeId::INTEGER},
+ {L"pid", TypeId::INTEGER},
+ {L"gid", TypeId::INTEGER},
+ {L"uid", TypeId::INTEGER},
{L"text", TypeId::STRING},
{L"data", TypeId::STRING}
}, true);
for (int i = configuration.messageCount; continueProcessing && i > 0; i--) {
// TODO: maybe rather call mq_timedreceive() inside and check continueProcessing (to be able to stop even when no messages are comming)
- std::string message = socket->receive();
+ IncomingMessage message = socket->receive();
- writer->writeAttribute(configuration.queue);
- writer->writeAttribute(Hex::toTxt(message));
- writer->writeAttribute(Hex::toHex(message));
+ writer->writeAttribute(convertor.from_bytes(message.remoteHost));
+ writer->writeAttribute(std::to_wstring(message.remotePort));
+ writer->writeAttribute(std::to_wstring(message.remotePID));
+ writer->writeAttribute(std::to_wstring(message.remoteGID));
+ writer->writeAttribute(std::to_wstring(message.remoteUID));
+ writer->writeAttribute(Hex::toTxt(message.data));
+ writer->writeAttribute(Hex::toHex(message.data));
}
}