Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send event stops geting vars #4

Open
SchmidtDawid opened this issue Mar 17, 2021 · 1 comment
Open

send event stops geting vars #4

SchmidtDawid opened this issue Mar 17, 2021 · 1 comment

Comments

@SchmidtDawid
Copy link

Is someone is able to help me?

func main() {
    sc, err := simconnect.NewEasySimConnect()
    if err != nil {
        panic(err)
    }
    go connectToSimVars(sc)

    time.Sleep(3 * time.Second)
    event := sc.NewSimEvent(simconnect.KeyAutopilotOff)
    event.Run()

    for {
                fmt.Println(sc.IsAlive())
        time.Sleep(time.Second * 3)
    }
}

func connectToSimVars(sc *simconnect.EasySimConnect) <-chan []simconnect.SimVar {
    cSimVar, err := sc.ConnectToSimVar(
        simconnect.SimVarPlaneAltitude(),
        simconnect.SimVarAutopilotMaster(),
    )
    if err != nil {
        panic(err)
    }

    for {
        result := <-cSimVar
        fmt.Println(result)
    }
}

after i run this program i get updated sim data few time every second. After i send event to sc loop in connectToSimVars() stops. But i still get info that sc is alive (last loop)

@jagobagascon
Copy link

Not sure if this is related but event.Run() returns a <-chan int32 that triggers when the event finishes. You are not reading from that channel so maybe the code is getting stuck somewhere? Have you tried to run <-event.Run() ? Its working fine for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants