29
29
#include < Client.h>
30
30
#include < Udp.h>
31
31
#include " ConnectionHandlerDefinitions.h"
32
+ #include " connectionHandlerModels/settings.h"
32
33
33
34
/* *****************************************************************************
34
35
TYPEDEFS
@@ -40,10 +41,13 @@ typedef void (*OnNetworkEventCallback)();
40
41
CLASS DECLARATION
41
42
******************************************************************************/
42
43
44
+ // forward declaration FIXME
45
+ class GenericConnectionHandler ;
46
+
43
47
class ConnectionHandler {
44
48
public:
45
49
46
- ConnectionHandler (bool const keep_alive, NetworkAdapter interface);
50
+ ConnectionHandler (bool const keep_alive= true , NetworkAdapter interface=NetworkAdapter::NONE );
47
51
48
52
49
53
NetworkConnectionState check ();
@@ -77,6 +81,22 @@ class ConnectionHandler {
77
81
void addDisconnectCallback (OnNetworkEventCallback callback) __attribute__((deprecated));
78
82
void addErrorCallback (OnNetworkEventCallback callback) __attribute__((deprecated));
79
83
84
+ /* *
85
+ * Update the interface settings. This can be performed only when the interface is
86
+ * in INIT state. otherwise nothing is performed. The type of the interface should match
87
+ * the type of the settings provided
88
+ *
89
+ * @return true if the update is successful, false otherwise
90
+ */
91
+ virtual bool updateSetting (const models::NetworkSetting& s) {
92
+ if (_current_net_connection_state == NetworkConnectionState::INIT && s.type == _interface) {
93
+ memcpy (&_settings, &s, sizeof (s));
94
+ return true ;
95
+ }
96
+
97
+ return false ;
98
+ }
99
+
80
100
protected:
81
101
82
102
bool _keep_alive;
@@ -88,12 +108,16 @@ class ConnectionHandler {
88
108
virtual NetworkConnectionState update_handleDisconnecting () = 0;
89
109
virtual NetworkConnectionState update_handleDisconnected () = 0;
90
110
111
+ models::NetworkSetting _settings;
112
+
91
113
private:
92
114
93
115
unsigned long _lastConnectionTickTime;
94
116
NetworkConnectionState _current_net_connection_state;
95
117
OnNetworkEventCallback _on_connect_event_callback = NULL ,
96
118
_on_disconnect_event_callback = NULL ,
97
119
_on_error_event_callback = NULL ;
120
+
121
+ friend GenericConnectionHandler;
98
122
};
99
123
0 commit comments