2929#include < Client.h>
3030#include < Udp.h>
3131#include " ConnectionHandlerDefinitions.h"
32+ #include " ConnectionHandlerModels/settings.h"
3233
3334/* *****************************************************************************
3435 TYPEDEFS
@@ -40,10 +41,13 @@ typedef void (*OnNetworkEventCallback)();
4041 CLASS DECLARATION
4142 ******************************************************************************/
4243
44+ // forward declaration FIXME
45+ class GenericConnectionHandler ;
46+
4347class ConnectionHandler {
4448 public:
4549
46- ConnectionHandler (bool const keep_alive, NetworkAdapter interface);
50+ ConnectionHandler (bool const keep_alive= true , NetworkAdapter interface=NetworkAdapter::NONE );
4751
4852
4953 NetworkConnectionState check ();
@@ -77,6 +81,22 @@ class ConnectionHandler {
7781 void addDisconnectCallback (OnNetworkEventCallback callback) __attribute__((deprecated));
7882 void addErrorCallback (OnNetworkEventCallback callback) __attribute__((deprecated));
7983
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+
80100 protected:
81101
82102 bool _keep_alive;
@@ -88,12 +108,16 @@ class ConnectionHandler {
88108 virtual NetworkConnectionState update_handleDisconnecting () = 0;
89109 virtual NetworkConnectionState update_handleDisconnected () = 0;
90110
111+ models::NetworkSetting _settings;
112+
91113 private:
92114
93115 unsigned long _lastConnectionTickTime;
94116 NetworkConnectionState _current_net_connection_state;
95117 OnNetworkEventCallback _on_connect_event_callback = NULL ,
96118 _on_disconnect_event_callback = NULL ,
97119 _on_error_event_callback = NULL ;
120+
121+ friend GenericConnectionHandler;
98122};
99123
0 commit comments