libnick 2024.9.2
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
networkmonitor.h
Go to the documentation of this file.
1
23#ifndef NETWORKMONITOR_H
24#define NETWORKMONITOR_H
25
26#include <mutex>
28#include "events/event.h"
29#ifdef _WIN32
30#include <windows.h>
31#include <atlbase.h>
32#include <netlistmgr.h>
33#endif
34
35namespace Nickvision::Network
36{
40#ifdef _WIN32
41 class NetworkMonitor : public INetworkListManagerEvents
42#else
44#endif
45 {
46 public:
66#ifdef _WIN32
67 ULONG STDMETHODCALLTYPE AddRef() override;
68 ULONG STDMETHODCALLTYPE Release() override;
69 HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) override;
70 HRESULT STDMETHODCALLTYPE ConnectivityChanged(NLM_CONNECTIVITY newConnectivity) override;
71 HRESULT STDMETHODCALLTYPE NetworkConnectionPropertyChanged(GUID connectionId, NLM_CONNECTION_PROPERTY_CHANGE newProperty);
72#endif
73
74 private:
78 void checkConnectionState();
79 mutable std::mutex m_mutex;
81 NetworkState m_connectionState;
82#ifdef _WIN32
83 CComPtr<INetworkListManager> m_netListManager;
84 CComPtr<IConnectionPoint> m_connectionPoint;
85 DWORD m_cookie;
86#else
87 unsigned long m_networkChangedHandlerId;
88#endif
89 };
90}
91
92#endif //NETWORKMONITOR_H
An event that can have handlers subscribe to it, which in turn will be called when the event is invok...
Definition event.h:49
A monitor of the system's network connection.
Definition networkmonitor.h:45
Events::Event< NetworkStateChangedEventArgs > & stateChanged()
Gets the StateChanged event. This event is invoked whenever the state of the network connection chang...
~NetworkMonitor()
Destructs a NetworkMonitor.
NetworkMonitor()
Constructs a NetworkMonitor. This method will call checkConnectionState() to get the initial system n...
NetworkState getConnectionState() const
Gets the state of the network connection.
Definition curleasy.h:33
NetworkState
States of a network connection.
Definition networkstate.h:32