27 #ifndef _SIGNALK_NET_H
28 #define _SIGNALK_NET_H
33 #include <wx/wxprec.h>
39 #include <wx/datetime.h>
40 #include <wx/socket.h>
42 #include "rapidjson/fwd.h"
43 #include "model/conn_params.h"
44 #include "model/comm_drv_signalk.h"
46 #define SIGNALK_SOCKET_ID 5011
47 #define N_DOG_TIMEOUT 5
48 #define N_DOG_TIMEOUT_RECONNECT 10
50 static const double ms_to_knot_factor = 1.9438444924406;
53 class OCPN_WebSocketMessageHandler;
63 static bool DiscoverSKServer(wxString &ip,
int &port,
int tSec);
64 static bool DiscoverSKServer(std::string serviceIdent, wxString &ip,
68 void SetThreadRunning(
bool active) { m_threadActive = active; }
69 void SetThreadRunFlag(
int run) { m_Thread_run_flag = run; }
70 void ResetWatchdog() { m_dog_value = N_DOG_TIMEOUT; }
71 void SetWatchdog(
int n) { m_dog_value = n; }
77 void handleUpdate(
const rapidjson::Value &update);
78 void updateItem(
const rapidjson::Value &item, wxString &sfixtime);
81 void CloseWebSocket();
82 bool IsThreadRunning() {
return m_threadActive == 1; }
85 std::string m_context;
87 std::atomic_int m_Thread_run_flag;
88 std::atomic_int m_threadActive;
93 static void initIXNetSystem();
95 static void uninitIXNetSystem();
99 wxIPV4address GetAddr()
const {
return m_addr; }
103 wxTimer m_socketread_watchdog_timer;
104 wxTimer *GetSocketThreadWatchdogTimer() {
105 return &m_socketread_watchdog_timer;
108 OCPN_WebSocketMessageHandler *m_eventHandler;
113 bool SetOutputSocketOptions(wxSocketBase *sock);
void Activate() override
Register driver and possibly do other post-ctor steps.
Interface implemented by transport layer and possible other parties like test code which should handl...