MirrorPropertyTree websocket fixes
- deal with ‘NONE’ properties correctly - use a better method to send the initial tree on connection.
This commit is contained in:
parent
d9cd65305a
commit
b767a33f84
1 changed files with 22 additions and 3 deletions
|
@ -44,7 +44,7 @@ using std::string;
|
||||||
struct PropertyValue
|
struct PropertyValue
|
||||||
{
|
{
|
||||||
PropertyValue(SGPropertyNode* cur = nullptr) :
|
PropertyValue(SGPropertyNode* cur = nullptr) :
|
||||||
type(simgear::props::UNSPECIFIED)
|
type(simgear::props::NONE)
|
||||||
{
|
{
|
||||||
if (!cur) {
|
if (!cur) {
|
||||||
return;
|
return;
|
||||||
|
@ -70,8 +70,11 @@ using std::string;
|
||||||
stringValue = cur->getStringValue();
|
stringValue = cur->getStringValue();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case simgear::props::NONE:
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
SG_LOG(SG_NETWORK, SG_INFO, "implement me!");
|
SG_LOG(SG_NETWORK, SG_INFO, "implement me!" << type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,6 +95,9 @@ using std::string;
|
||||||
case simgear::props::UNSPECIFIED:
|
case simgear::props::UNSPECIFIED:
|
||||||
return stringValue == other.stringValue;
|
return stringValue == other.stringValue;
|
||||||
|
|
||||||
|
case simgear::props::NONE:
|
||||||
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -146,6 +152,19 @@ using std::string;
|
||||||
removedNodes.insert(idForProperty(child));
|
removedNodes.insert(idForProperty(child));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void registerSubtree(SGPropertyNode* node)
|
||||||
|
{
|
||||||
|
if (node->getType() != simgear::props::NONE) {
|
||||||
|
valueChanged(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
// and recurse
|
||||||
|
int child = 0;
|
||||||
|
for (; child < node->nChildren(); ++child) {
|
||||||
|
registerSubtree(node->getChild(child));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::set<SGPropertyNode*> newNodes;
|
std::set<SGPropertyNode*> newNodes;
|
||||||
std::set<SGPropertyNode*> changedNodes;
|
std::set<SGPropertyNode*> changedNodes;
|
||||||
std::set<PropertyId> removedNodes;
|
std::set<PropertyId> removedNodes;
|
||||||
|
@ -281,7 +300,7 @@ MirrorPropertyTreeWebsocket::MirrorPropertyTreeWebsocket(const std::string& path
|
||||||
{
|
{
|
||||||
_subtreeRoot = globals->get_props()->getNode(path, true);
|
_subtreeRoot = globals->get_props()->getNode(path, true);
|
||||||
_subtreeRoot->addChangeListener(_listener.get());
|
_subtreeRoot->addChangeListener(_listener.get());
|
||||||
_subtreeRoot->fireCreatedRecursive();
|
_listener->registerSubtree(_subtreeRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
MirrorPropertyTreeWebsocket::~MirrorPropertyTreeWebsocket()
|
MirrorPropertyTreeWebsocket::~MirrorPropertyTreeWebsocket()
|
||||||
|
|
Loading…
Add table
Reference in a new issue