@@ -20,7 +20,7 @@ AutoNetServerImpl::AutoNetServerImpl(void):
2020 AutoNetServerImpl(std::unique_ptr<AutoNetTransportHttp>(new AutoNetTransportHttp))
2121{
2222 auto * pCtxt = AutoCurrentContext ().get ();
23- pCtxt->newContext += [this ] (CoreContext* pChild) { NewContext (*pChild); };
23+ pCtxt->newContext += [this , pCtxt ] (CoreContext* pChild) { NewContext (pCtxt, *pChild); };
2424 pCtxt->expiredContext += [this , pCtxt] { ExpiredContext (*pCtxt); };
2525 pCtxt->newObject += [this , pCtxt] (const CoreObjectDescriptor& desc) { NewObject (*pCtxt, desc); };
2626}
@@ -153,16 +153,27 @@ void AutoNetServerImpl::Breakpoint(std::string name){
153153}
154154
155155// Update Functions
156- void AutoNetServerImpl::NewContext (CoreContext& newCtxt){
156+ void AutoNetServerImpl::NewContext (CoreContext* pParent, CoreContext & newCtxt) {
157157 auto ctxt = newCtxt.shared_from_this ();
158158
159- *this += [this , ctxt] {
159+ // Need teardown and child creation notifications
160+ newCtxt.newContext += [this , &newCtxt] (CoreContext* pChild) {
161+ NewContext (&newCtxt, *pChild);
162+ };
163+ newCtxt.expiredContext += [this , &newCtxt] {
164+ ExpiredContext (newCtxt);
165+ };
166+ newCtxt.newObject += [this , &newCtxt](const CoreObjectDescriptor& desc) {
167+ NewObject (newCtxt, desc);
168+ };
169+
170+ *this += [this , pParent, ctxt] {
160171 Json::object context{
161172 {" name" , autowiring::demangle (ctxt->GetSigilType ())}
162173 };
163174
164- if (ctxt != GetContext () && ctxt-> GetParentContext () )
165- context[" parent" ] = ResolveContextID (ctxt-> GetParentContext (). get () );
175+ if (pParent )
176+ context[" parent" ] = ResolveContextID (pParent );
166177
167178 BroadcastMessage (" newContext" , ResolveContextID (ctxt.get ()), context);
168179 };
@@ -284,9 +295,13 @@ void AutoNetServerImpl::HandleSubscribe(websocketpp::connection_hdl hdl) {
284295
285296 SendMessage (hdl, " subscribed" , types);
286297
298+ auto root = GetContext ();
287299 for (auto ctxt : ContextEnumerator{ GetContext () }) {
288300 // Send update about this newly discovered context
289- NewContext (*ctxt);
301+ NewContext (
302+ ctxt == root ? nullptr : ctxt->GetParentContext ().get (),
303+ *ctxt
304+ );
290305
291306 // Build total image of all objects, recursively:
292307 for (const auto * pObj : ctxt->BuildObjectState ())
0 commit comments