diff --git a/src/Network/http/PropertyChangeObserver.cxx b/src/Network/http/PropertyChangeObserver.cxx index 85272ff7d..6594c2d0a 100644 --- a/src/Network/http/PropertyChangeObserver.cxx +++ b/src/Network/http/PropertyChangeObserver.cxx @@ -50,6 +50,14 @@ void PropertyChangeObserver::check() if ((*it)->_changed) (*it)->_prevValue = (*it)->_node->getStringValue(); } } + +void PropertyChangeObserver::uncheck() +{ + for (Entries_t::iterator it = _entries.begin(); it != _entries.end(); ++it) { + (*it)->_changed = false; + } +} + const SGPropertyNode_ptr PropertyChangeObserver::addObservation( const string propertyName) { for (Entries_t::iterator it = _entries.begin(); it != _entries.end(); ++it) { @@ -72,14 +80,12 @@ const SGPropertyNode_ptr PropertyChangeObserver::addObservation( const string pr return empty; } -bool PropertyChangeObserver::getChangedValue(const SGPropertyNode_ptr node, string & out) +bool PropertyChangeObserver::isChangedValue(const SGPropertyNode_ptr node) { for (Entries_t::iterator it = _entries.begin(); it != _entries.end(); ++it) { PropertyChangeObserverEntryRef entry = *it; if( entry->_node == node && entry->_changed ) { - out = entry->_node->getStringValue(); - entry->_changed = false; return true; } } diff --git a/src/Network/http/PropertyChangeObserver.hxx b/src/Network/http/PropertyChangeObserver.hxx index d57637338..a81571583 100644 --- a/src/Network/http/PropertyChangeObserver.hxx +++ b/src/Network/http/PropertyChangeObserver.hxx @@ -46,9 +46,10 @@ public: virtual ~PropertyChangeObserver(); const SGPropertyNode_ptr addObservation( const std::string propertyName); - bool getChangedValue(const SGPropertyNode_ptr node, std::string & out); + bool isChangedValue(const SGPropertyNode_ptr node); void check(); + void uncheck(); private: typedef std::vector Entries_t; diff --git a/src/Network/http/PropertyChangeWebsocket.cxx b/src/Network/http/PropertyChangeWebsocket.cxx index 2bd77acad..bfe5841b6 100644 --- a/src/Network/http/PropertyChangeWebsocket.cxx +++ b/src/Network/http/PropertyChangeWebsocket.cxx @@ -95,8 +95,8 @@ void PropertyChangeWebsocket::update(WebsocketWriter & writer) SGPropertyNode_ptr node = *it; string newValue; - if (_propertyChangeObserver->getChangedValue(node, newValue)) { - SG_LOG(SG_NETWORK, SG_ALERT, "httpd: new Value for " << node->getPath(true) << " '" << newValue << "' #" << id); + if (_propertyChangeObserver->isChangedValue(node)) { + SG_LOG(SG_NETWORK, SG_ALERT, "httpd: new Value for " << node->getPath(true) << " '" << node->getStringValue() << "' #" << id); writer.writeText( JSON::toJsonString( false, node, 0 ) ); } } diff --git a/src/Network/http/httpd.cxx b/src/Network/http/httpd.cxx index 6575b0b83..c85b7d43a 100644 --- a/src/Network/http/httpd.cxx +++ b/src/Network/http/httpd.cxx @@ -172,6 +172,7 @@ void MongooseHttpd::update(double dt) _propertyChangeObserver.check(); mg_poll_server(_server, 0); mg_iterate_over_connections(_server, &MongooseHttpd::staticIterateCallback); + _propertyChangeObserver.uncheck(); } class MongooseHTTPRequest: public HTTPRequest {