using System;
using System.Threading.Tasks;
namespace SimConnect
{
public enum SimConnectSystemEvent
{
///
/// Request notifications when the flight is paused or unpaused. args will be of type SimConnectPauseSystemEventArgs.
///
Pause,
///
/// Request notifications when the flight is running or not. args will be of type SimConnectSimSystemEventArgs.
///
Sim
}
public abstract class SimConnectSystemEventArgs
{
}
public class SimConnectPauseSystemEventArgs : SimConnectSystemEventArgs
{
public bool Paused { get; set; }
}
public class SimConnectSimSystemEventArgs : SimConnectSystemEventArgs
{
public bool SimRunning { get; set; }
}
public delegate Task SimConnectSystemEventAction(SimConnectSystemEventArgs args);
///
/// Called when new data arrives from the SimConnect server.
///
/// An instance of the data class as passed to AddDefinition containing the variable values
/// The data class as passed to AddDefinition
public delegate Task SimConnectDataHandlerAction(T data) where T : class;
///
/// Gets notified of changes to the SimConnect state.
///
public interface ISimConnectClientObserver
{
///
/// Gets called when the SimConnect connection is lost. The client will not receive further notifications,
/// a new connection should be attempted if desired.
///
void OnQuit();
}
///
/// Provides access to the SimConnect library.
///
public interface ISimConnectClient : IAsyncDisposable
{
///
/// Attaches the specified observer to receive status notifications.
///
/// The observer to receive status notifications
void AttachObserver(ISimConnectClientObserver observer);
///
/// Registers a definition to receive updates from the SimConnect server.
///
/// A callback method which is called whenever a data update is received
/// A class defining the variables to monitor annotated using the SimConnectVariable attribute
/// An IAsyncDisposable which can be disposed to unregister the definition. Dispose is not required to be called when the client is disconnected, but will not throw an exception.
IAsyncDisposable AddDefinition(SimConnectDataHandlerAction onData) where T : class;
///
/// Subscribes to a SimConnect system event.
///
/// The type of event to subscribe to.
/// The callback method called whenever the system event occurs.
/// An IAsyncDisposable which can be disposed to unregister the definition. Dispose is not required to be called when the client is disconnected, but will not throw an exception.
IAsyncDisposable SubscribeToSystemEvent(SimConnectSystemEvent systemEvent, SimConnectSystemEventAction onEvent);
}
}