mirror of
https://github.com/ehang-io/nps.git
synced 2025-07-03 04:53:50 +00:00
add log for sdk
This commit is contained in:
parent
34fcd15101
commit
cb1cc67e6b
@ -2,45 +2,50 @@ package main
|
|||||||
|
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
|
"github.com/astaxie/beego/logs"
|
||||||
"github.com/cnlh/nps/client"
|
"github.com/cnlh/nps/client"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var status bool
|
func init() {
|
||||||
var closeBefore bool
|
logs.SetLogger(logs.AdapterFile, `{"filename":"npc.log","daily":false,"maxlines":100000,"color":true}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
var status int
|
||||||
|
var closeBefore int
|
||||||
var cl *client.TRPClient
|
var cl *client.TRPClient
|
||||||
|
|
||||||
//export StartClientByVerifyKey
|
//export StartClientByVerifyKey
|
||||||
func StartClientByVerifyKey(serverAddr, verifyKey, connType, proxyUrl *C.char) bool {
|
func StartClientByVerifyKey(serverAddr, verifyKey, connType, proxyUrl *C.char) int {
|
||||||
if cl != nil {
|
if cl != nil {
|
||||||
closeBefore = true
|
closeBefore = 1
|
||||||
cl.Close()
|
cl.Close()
|
||||||
}
|
}
|
||||||
cl = client.NewRPClient(C.GoString(serverAddr), C.GoString(verifyKey), C.GoString(connType), C.GoString(proxyUrl), nil)
|
cl = client.NewRPClient(C.GoString(serverAddr), C.GoString(verifyKey), C.GoString(connType), C.GoString(proxyUrl), nil)
|
||||||
closeBefore = false
|
closeBefore = 0
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
status = true
|
status = 1
|
||||||
cl.Start()
|
cl.Start()
|
||||||
status = false
|
status = 0
|
||||||
if closeBefore {
|
if closeBefore == 1 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second * 5)
|
time.Sleep(time.Second * 5)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return true
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
//export GetClientStatus
|
//export GetClientStatus
|
||||||
func GetClientStatus() bool {
|
func GetClientStatus() int {
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
|
|
||||||
//export CloseClient
|
//export CloseClient
|
||||||
func CloseClient() {
|
func CloseClient() {
|
||||||
|
closeBefore = 1
|
||||||
cl.Close()
|
cl.Close()
|
||||||
closeBefore = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user