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