@@ -20,7 +20,7 @@ AutoNetServerImpl::AutoNetServerImpl(void):
20
20
AutoNetServerImpl(std::unique_ptr<AutoNetTransportHttp>(new AutoNetTransportHttp))
21
21
{
22
22
auto * pCtxt = AutoCurrentContext ().get ();
23
- pCtxt->newContext += [this ] (CoreContext* pChild) { NewContext (*pChild); };
23
+ pCtxt->newContext += [this , pCtxt ] (CoreContext* pChild) { NewContext (pCtxt, *pChild); };
24
24
pCtxt->expiredContext += [this , pCtxt] { ExpiredContext (*pCtxt); };
25
25
pCtxt->newObject += [this , pCtxt] (const CoreObjectDescriptor& desc) { NewObject (*pCtxt, desc); };
26
26
}
@@ -153,16 +153,27 @@ void AutoNetServerImpl::Breakpoint(std::string name){
153
153
}
154
154
155
155
// Update Functions
156
- void AutoNetServerImpl::NewContext (CoreContext& newCtxt){
156
+ void AutoNetServerImpl::NewContext (CoreContext* pParent, CoreContext & newCtxt) {
157
157
auto ctxt = newCtxt.shared_from_this ();
158
158
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] {
160
171
Json::object context{
161
172
{" name" , autowiring::demangle (ctxt->GetSigilType ())}
162
173
};
163
174
164
- if (ctxt != GetContext () && ctxt-> GetParentContext () )
165
- context[" parent" ] = ResolveContextID (ctxt-> GetParentContext (). get () );
175
+ if (pParent )
176
+ context[" parent" ] = ResolveContextID (pParent );
166
177
167
178
BroadcastMessage (" newContext" , ResolveContextID (ctxt.get ()), context);
168
179
};
@@ -284,9 +295,13 @@ void AutoNetServerImpl::HandleSubscribe(websocketpp::connection_hdl hdl) {
284
295
285
296
SendMessage (hdl, " subscribed" , types);
286
297
298
+ auto root = GetContext ();
287
299
for (auto ctxt : ContextEnumerator{ GetContext () }) {
288
300
// Send update about this newly discovered context
289
- NewContext (*ctxt);
301
+ NewContext (
302
+ ctxt == root ? nullptr : ctxt->GetParentContext ().get (),
303
+ *ctxt
304
+ );
290
305
291
306
// Build total image of all objects, recursively:
292
307
for (const auto * pObj : ctxt->BuildObjectState ())
0 commit comments