mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-02 03:16:53 +00:00
update sdk
This commit is contained in:
@@ -6,44 +6,31 @@ import (
|
||||
"github.com/cnlh/nps/client"
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
"github.com/cnlh/nps/lib/version"
|
||||
"time"
|
||||
)
|
||||
|
||||
var status int
|
||||
var closeBefore int
|
||||
var cl *client.TRPClient
|
||||
|
||||
//export StartClientByVerifyKey
|
||||
func StartClientByVerifyKey(serverAddr, verifyKey, connType, proxyUrl *C.char) int {
|
||||
logs.SetLogger("store")
|
||||
if cl != nil {
|
||||
closeBefore = 1
|
||||
cl.Close()
|
||||
}
|
||||
cl = client.NewRPClient(C.GoString(serverAddr), C.GoString(verifyKey), C.GoString(connType), C.GoString(proxyUrl), nil)
|
||||
closeBefore = 0
|
||||
go func() {
|
||||
for {
|
||||
status = 1
|
||||
cl.Start()
|
||||
status = 0
|
||||
if closeBefore == 1 {
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Second * 5)
|
||||
}
|
||||
cl.Start()
|
||||
return
|
||||
}()
|
||||
return 1
|
||||
}
|
||||
|
||||
//export GetClientStatus
|
||||
func GetClientStatus() int {
|
||||
return status
|
||||
return client.NowStatus
|
||||
}
|
||||
|
||||
//export CloseClient
|
||||
func CloseClient() {
|
||||
closeBefore = 1
|
||||
cl.Close()
|
||||
}
|
||||
|
||||
@@ -51,6 +38,7 @@ func CloseClient() {
|
||||
func Version() *C.char {
|
||||
return C.CString(version.VERSION)
|
||||
}
|
||||
|
||||
//export Logs
|
||||
func Logs() *C.char {
|
||||
return C.CString(common.GetLogMsg())
|
||||
|
Reference in New Issue
Block a user