Friday, March 1, 2024

Learning to use SimConnect: Part Two - SimConnect Messages

 In my first post about SimConnect, I showed how to create a simple C# console app that connected to the SimConnect server running within Microsoft Flight Simulator 2020, using the managed SimConnect library. Now let's talk about how to actually interact with the simulator in a (somewhat) useful fashion.

I have a GitHub repository with all the code from this series in it, tagged at each stage. If you want to start out with the code as it was at the end of the first post, use the tag "03-add-a-pause".

SimConnect client/server communication is primarily through a set of defined data structures called messages. Clients receive these messages periodically from the server and either ignore the message, or take action, based on the kind of message received. In this model, the simulation engine itself is a client of the SimConnect server, so in order to control the simulation, we send messages from our client to the server, which the simulation engine then receives as a client. To start with, let's look at how we can receive messages from SimConnect.