mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-02 03:16:53 +00:00
update npc sdk and version
This commit is contained in:
@@ -2,32 +2,47 @@ package main
|
||||
|
||||
import "C"
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cnlh/nps/client"
|
||||
"time"
|
||||
)
|
||||
|
||||
//export PrintBye
|
||||
func PrintBye() {
|
||||
fmt.Println("From DLL: Bye!")
|
||||
}
|
||||
|
||||
var status bool
|
||||
var closeBefore bool
|
||||
var cl *client.TRPClient
|
||||
|
||||
//export Sum
|
||||
func StartClientByVerifyKey(a int, b int) bool {
|
||||
c := client.NewRPClient(*serverAddr, *verifyKey, *connType, *proxyUrl, nil)
|
||||
//export StartClientByVerifyKey
|
||||
func StartClientByVerifyKey(serverAddr, verifyKey, connType, proxyUrl string) bool {
|
||||
if cl != nil {
|
||||
closeBefore = true
|
||||
cl.Close()
|
||||
}
|
||||
cl = client.NewRPClient(serverAddr, verifyKey, connType, proxyUrl, nil)
|
||||
closeBefore = false
|
||||
go func() {
|
||||
for {
|
||||
status = true
|
||||
c.Start()
|
||||
cl.Start()
|
||||
status = false
|
||||
if closeBefore {
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Second * 5)
|
||||
}
|
||||
}()
|
||||
return true
|
||||
}
|
||||
|
||||
//export GetClientStatus
|
||||
func GetClientStatus() bool {
|
||||
return status
|
||||
}
|
||||
|
||||
//export CloseClient
|
||||
func CloseClient() {
|
||||
cl.Close()
|
||||
closeBefore = true
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Need a main function to make CGO compile package as C shared library
|
||||
}
|
||||
|
Reference in New Issue
Block a user