Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsReport ¶
func IsReport[T any](s *client.SimConnect, ppData *client.RecvSimobjectDataByType) (*T, bool)
IsReport Convenience function to check if the data is the correct type
func RequestData ¶
func RequestData[T any](s *client.SimConnect) error
RequestData Convenience function to request data
Types ¶
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
Connector is the main struct for connecting to SimConnect
func NewConnector ¶
func NewConnector(name string, opts ...ConnectorOption) *Connector
NewConnector creates a new connector you can pass options to the connector
func (*Connector) Start ¶
Start starts the connector it will connect to SimConnect and start the receivers this is BLOCKING, and will terminate at the first disconnect
func (*Connector) StartReconnect ¶
StartReconnect starts the connector with reconnect it will connect to SimConnect and start the receivers this is BLOCKING, and will reconnect on disconnect This is a simple wrapper around Start that adds a exponential backoff
type ConnectorError ¶
type ConnectorError string
ConnectorError is the error type for the connector
const ( // ErrE_FAIL is the error for E_FAIL ErrE_FAIL ConnectorError = "E_FAIL" // ErrGetNextDispatch is the error for GetNextDispatch ErrGetNextDispatch ConnectorError = "GetNextDispatch" )
func (ConnectorError) Error ¶
func (e ConnectorError) Error() string
type ConnectorOption ¶
type ConnectorOption func(*Connector)
ConnectorOption is a function that sets options on the Connector
func WithCycle ¶
func WithCycle(cycle time.Duration) ConnectorOption
WithCycle sets the cycle time for the connector the connector will dispatch data every cycle
func WithDLLPath ¶
func WithDLLPath(path string) ConnectorOption
WithDLLPath sets the path to the SimConnect DLL if not set, the default DLL will be used
func WithLogger ¶
func WithLogger(l *slog.Logger) ConnectorOption
WithLogger sets the logger for the connector
func WithReceiver ¶
func WithReceiver(r Receiver) ConnectorOption
WithReceiver adds a receiver to the connector you can add multiple receivers
type Receiver ¶
type Receiver interface { // Start is called when the receiver is started // it gets called after the connection is established // and whenever a reconnection happens // the context is cancelled when the connection is lost // this may be called multiple times if the connection is lost and re-established Start(ctx context.Context, sc *client.SimConnect) // Update is called whenever a new data packet is received // the context is cancelled when the connection is lost // this may be called multiple times over the life of the connection Update(ctx context.Context, sc *client.SimConnect, ppData *client.RecvSimobjectDataByType) }
Receiver is the interface for receiving data from SimConnect