1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package main
- import "C"
- import (
- "github.com/astaxie/beego/logs"
- "github.com/cnlh/nps/client"
- "time"
- )
- 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
- func StartClientByVerifyKey(serverAddr, verifyKey, connType, proxyUrl *C.char) int {
- 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)
- }
- }()
- return 1
- }
- func GetClientStatus() int {
- return status
- }
- func CloseClient() {
- closeBefore = 1
- cl.Close()
- }
- func main() {
-
- }
|