mirror of
https://github.com/eclipse-openvehicle-api/openvehicle-api.git
synced 2026-08-30 12:15:12 +00:00
connection between 2 systems and bug fixes (#14)
This commit is contained in:
@@ -16,18 +16,15 @@
|
||||
|
||||
#include <support/component_impl.h>
|
||||
#include <interfaces/ipc.h>
|
||||
#include "../sdv_services/uds_win_sockets/channel_mgnt.h"
|
||||
#include "../sdv_services/uds_win_sockets/connection.h"
|
||||
#include "connection.h"
|
||||
#include "watchdog.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
// Winsock headers are required for SOCKET / AF_UNIX / WSAStartup
|
||||
// NOTE: The actual initialization is done via StartUpWinSock()
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
class CWinTunnelConnection;
|
||||
@@ -56,8 +53,8 @@ public:
|
||||
|
||||
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::system_object)
|
||||
DECLARE_OBJECT_CLASS_NAME("WinTunnelChannelControl")
|
||||
DECLARE_OBJECT_CLASS_ALIAS("LocalChannelControl")
|
||||
DECLARE_DEFAULT_OBJECT_NAME("LocalChannelControl")
|
||||
DECLARE_OBJECT_CLASS_ALIAS("unix_domain_sockets_tunnel")
|
||||
DECLARE_DEFAULT_OBJECT_NAME("unix_domain_sockets_tunnel")
|
||||
DECLARE_OBJECT_SINGLETON()
|
||||
|
||||
virtual ~CSocketsTunnelChannelMgnt() = default;
|
||||
@@ -73,6 +70,11 @@ public:
|
||||
*/
|
||||
virtual void OnShutdown() override;
|
||||
|
||||
/**
|
||||
* @brief Last function called before destruction. Overload of sdv::CSdvObject::OnDestroy.
|
||||
*/
|
||||
virtual void OnDestroy() override;
|
||||
|
||||
/**
|
||||
* @brief Creates a tunnel endpoint (server side) and returns endpoint info.
|
||||
* @param[in] cfgStr Optional config string (TOML or connect string).
|
||||
@@ -87,17 +89,10 @@ public:
|
||||
*/
|
||||
sdv::IInterfaceAccess* Access(const sdv::u8string& cs) override;
|
||||
|
||||
/**
|
||||
* @brief Called by server tunnel when closing (bookkeeping).
|
||||
* @param[in] udsPath The UDS path for the server.
|
||||
* @param[in] ptr Pointer to the tunnel connection being closed.
|
||||
*/
|
||||
void OnServerClosed(const std::string& udsPath, CWinTunnelConnection* ptr);
|
||||
|
||||
private:
|
||||
std::mutex m_udsMtx;
|
||||
std::map<std::string, std::shared_ptr<CWinTunnelConnection>> m_udsServers;
|
||||
std::set<std::string> m_udsServerClaimed;
|
||||
CWinTunnelConnectionWatchDog m_watchdog;
|
||||
std::map<const void*, std::shared_ptr<CWinTunnelConnection>> m_ptrConnections; ///< Retain shared_ptr for all connections
|
||||
mutable std::mutex m_ConnectionsMutex; ///< Protect concurrent access to m_ptrConnections
|
||||
};
|
||||
|
||||
DEFINE_SDV_OBJECT(CSocketsTunnelChannelMgnt)
|
||||
|
||||
Reference in New Issue
Block a user