update npc sdk and version

This commit is contained in:
刘河
2019-12-04 01:54:23 +08:00
parent 08f7c1844a
commit 01a4bcf13d
2 changed files with 33 additions and 12 deletions

View File

@@ -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
}