mirror of
https://github.com/ehang-io/nps.git
synced 2025-07-06 07:20:44 +00:00
update npc sdk and version
This commit is contained in:
parent
08f7c1844a
commit
01a4bcf13d
10
.travis.yml
10
.travis.yml
@ -7,7 +7,9 @@ services:
|
|||||||
- docker
|
- docker
|
||||||
script:
|
script:
|
||||||
- go test -v ./cmd/nps/
|
- go test -v ./cmd/nps/
|
||||||
|
os:
|
||||||
|
- linux
|
||||||
|
- windows
|
||||||
before_deploy:
|
before_deploy:
|
||||||
- wget https://github.com/upx/upx/releases/download/v3.95/upx-3.95-amd64_linux.tar.xz
|
- wget https://github.com/upx/upx/releases/download/v3.95/upx-3.95-amd64_linux.tar.xz
|
||||||
- tar -xvf upx-3.95-amd64_linux.tar.xz
|
- tar -xvf upx-3.95-amd64_linux.tar.xz
|
||||||
@ -162,7 +164,7 @@ before_deploy:
|
|||||||
|
|
||||||
- tar -czvf win_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps.exe
|
- tar -czvf win_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps.exe
|
||||||
|
|
||||||
- export VERSION=0.24.2
|
- export VERSION=0.24.3
|
||||||
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
||||||
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
||||||
- sudo apt-get update
|
- sudo apt-get update
|
||||||
@ -174,6 +176,9 @@ before_deploy:
|
|||||||
- docker exec -it spksrc /bin/bash -c 'cd /spksrc && make setup && cd /spksrc/spk/npc && make'
|
- docker exec -it spksrc /bin/bash -c 'cd /spksrc && make setup && cd /spksrc/spk/npc && make'
|
||||||
- cp ~/spksrc/packages/npc_noarch-all_$VERSION-1.spk ./npc_$VERSION.spk
|
- cp ~/spksrc/packages/npc_noarch-all_$VERSION-1.spk ./npc_$VERSION.spk
|
||||||
|
|
||||||
|
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then go build -buildmode=c-shared -o npc_sdk.dll cmd\npc\sdk.go ; fi
|
||||||
|
- tar -czvf npc_sdk.tar.gz npc_sdk.dll npc_sdk.h
|
||||||
|
|
||||||
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||||
- export DOCKER_CLI_EXPERIMENTAL=enabled
|
- export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||||
- docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d
|
- docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d
|
||||||
@ -220,6 +225,7 @@ deploy:
|
|||||||
- win_amd64_client.tar.gz
|
- win_amd64_client.tar.gz
|
||||||
- win_amd64_server.tar.gz
|
- win_amd64_server.tar.gz
|
||||||
- npc_$VERSION.spk
|
- npc_$VERSION.spk
|
||||||
|
- nnpc_sdk.tar.gz
|
||||||
on:
|
on:
|
||||||
tags: true
|
tags: true
|
||||||
all_branches: true
|
all_branches: true
|
||||||
|
@ -2,32 +2,47 @@ package main
|
|||||||
|
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/cnlh/nps/client"
|
"github.com/cnlh/nps/client"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
//export PrintBye
|
|
||||||
func PrintBye() {
|
|
||||||
fmt.Println("From DLL: Bye!")
|
|
||||||
}
|
|
||||||
|
|
||||||
var status bool
|
var status bool
|
||||||
|
var closeBefore bool
|
||||||
|
var cl *client.TRPClient
|
||||||
|
|
||||||
//export Sum
|
//export StartClientByVerifyKey
|
||||||
func StartClientByVerifyKey(a int, b int) bool {
|
func StartClientByVerifyKey(serverAddr, verifyKey, connType, proxyUrl string) bool {
|
||||||
c := client.NewRPClient(*serverAddr, *verifyKey, *connType, *proxyUrl, nil)
|
if cl != nil {
|
||||||
|
closeBefore = true
|
||||||
|
cl.Close()
|
||||||
|
}
|
||||||
|
cl = client.NewRPClient(serverAddr, verifyKey, connType, proxyUrl, nil)
|
||||||
|
closeBefore = false
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
status = true
|
status = true
|
||||||
c.Start()
|
cl.Start()
|
||||||
status = false
|
status = false
|
||||||
|
if closeBefore {
|
||||||
|
return
|
||||||
|
}
|
||||||
time.Sleep(time.Second * 5)
|
time.Sleep(time.Second * 5)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//export GetClientStatus
|
||||||
|
func GetClientStatus() bool {
|
||||||
|
return status
|
||||||
|
}
|
||||||
|
|
||||||
|
//export CloseClient
|
||||||
|
func CloseClient() {
|
||||||
|
cl.Close()
|
||||||
|
closeBefore = true
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Need a main function to make CGO compile package as C shared library
|
// Need a main function to make CGO compile package as C shared library
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user