123456789101112131415161718192021222324252627282930313233343536373839 |
- // acetone, 2024
- // I hate copyright of any kind. This is a public domain.
- // Original source: https://notabug.org/acetone/samty
- #pragma once
- #include "i2psam.h"
- #include <thread>
- #include <atomic>
- namespace Samty {
- using PendingConnectionCallbackPointer = void (*)(const std::string& b32, std::unique_ptr<I2pSocket> socket);
- class SAMServer
- {
- public:
- SAMServer(const Samty::Configuration& samConfiguration,
- PendingConnectionCallbackPointer callback);
- virtual ~SAMServer() { stop(); }
- std::string myAddress() const;
- bool isOk() const;
- std::string errorString() const;
- bool start();
- void stop(); // Object is broken after this called
- protected:
- void loop();
- StreamSession m_streamSession;
- PendingConnectionCallbackPointer m_connectionCallback;
- std::thread m_mainThread;
- std::atomic<bool> m_started = false;
- };
- } // namespace Samty
|