Is the C# OnRecvEventObjectAddremove broken?

minime
Posts: 1198
Joined: Mon Jun 10, 2013 4:33 pm

Postby minime » Tue Aug 13, 2013 5:32 am



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!


minime
Posts: 1198
Joined: Mon Jun 10, 2013 4:33 pm

Postby minime » Wed Aug 14, 2013 5:46 am



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.

Premek
Posts: 24
Joined: Thu Nov 15, 2012 10:32 am

Postby Premek » Wed Aug 14, 2013 6:05 am

Thanks for sharing this minime ;)



Well, the documentation... :(

FSMP
Posts: 678
Joined: Sat Sep 25, 2010 9:38 am

Postby FSMP » Wed Aug 14, 2013 11:29 am



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.




Good find Minime :)





Return to “Software Development Kit (SDK) Questions”

Who is online

Users browsing this forum: No registered users and 37 guests