Is the C# OnRecvEventObjectAddremove broken?
I do this:
conn.OnRecvEventObjectAddremove += new SimConnect.RecvEventObjectAddremoveEventHandler(simconnect_OnRecvEventObjectAddremove);
and I confirmed that the function is never triggered. I checked about ANY mistake I could have made and I didnt find any. I also confirmed that there are tons of GAT and airliners added and removed in the client, and that I am connected.
I also added and removed objects manually, but whatever I do, the event never happens.
All the other EventHandlers work just fine (although of course the managed "OnRecvSimobjectDataBytype" is trashing memory so I had to remove it, but at least its being called).
Can anyone confirm that this event is broken on the managed SimConnect client? Or confirm it is working?
Thx!
Yeah, it is broken. Sort of. They forgot to enable the event in the C# wrapper, so it does not work like the other events.
I debugged it with a C++ client to see how it works in C++, and found the problem... in C# you have to subscribe, like in C++.
Here are the missing parts:
conn.SubscribeToSystemEvent(Events.OBJECT_ADDED, "ObjectAdded");
conn.SubscribeToSystemEvent(Events.OBJECT_REMOVED, "ObjectRemoved");
After you subscribe, the event works like it should.
This should be fixed. The managed wrapper should automatically do these calls when someone subscribes to the event with:
conn.OnRecvEventObjectAddremove += new SimConnect.RecvEventObjectAddremoveEventHandler(simconnect_OnRecvEventObjectAddremove);
and also should unsubscribe automatically when the last function is unsubscribed.
If the documentation of the managed SimConnect client wasn't that poor, I would not have wasted hours debugging this.
Quote:
Quote from minime on August 14, 2013, 05:46
Yeah, it is broken. Sort of. They forgot to enable the event in the C# wrapper, so it does not work like the other events.
I debugged it with a C++ client to see how it works in C++, and found the problem... in C# you have to subscribe, like in C++.
Here are the missing parts:
conn.SubscribeToSystemEvent(Events.OBJECT_ADDED, "ObjectAdded");
conn.SubscribeToSystemEvent(Events.OBJECT_REMOVED, "ObjectRemoved");
After you subscribe, the event works like it should.
This should be fixed. The managed wrapper should automatically do these calls when someone subscribes to the event with:
conn.OnRecvEventObjectAddremove += new SimConnect.RecvEventObjectAddremoveEventHandler(simconnect_OnRecvEventObjectAddremove);
and also should unsubscribe automatically when the last function is unsubscribed.
If the documentation of the managed SimConnect client wasn't that poor, I would not have wasted hours debugging this.
Yeah, it is broken. Sort of. They forgot to enable the event in the C# wrapper, so it does not work like the other events.
I debugged it with a C++ client to see how it works in C++, and found the problem... in C# you have to subscribe, like in C++.
Here are the missing parts:
conn.SubscribeToSystemEvent(Events.OBJECT_ADDED, "ObjectAdded");
conn.SubscribeToSystemEvent(Events.OBJECT_REMOVED, "ObjectRemoved");
After you subscribe, the event works like it should.
This should be fixed. The managed wrapper should automatically do these calls when someone subscribes to the event with:
conn.OnRecvEventObjectAddremove += new SimConnect.RecvEventObjectAddremoveEventHandler(simconnect_OnRecvEventObjectAddremove);
and also should unsubscribe automatically when the last function is unsubscribed.
If the documentation of the managed SimConnect client wasn't that poor, I would not have wasted hours debugging this.
Good find Minime :)
Return to “Software Development Kit (SDK) Questions”
Who is online
Users browsing this forum: No registered users and 26 guests