Skip to content

Commit

Permalink
Merge pull request #2 from ciisaichan/master
Browse files Browse the repository at this point in the history
稳定性更新
  • Loading branch information
Mrs4s authored May 23, 2020
2 parents 15208bb + 1dc6877 commit b9d1884
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ DD@Home in golang
./DDatHome uninstall
```

#### 配置文件
#### 配置文件 "config.json"
配置文件需要和主程序放在同一个目录下
```
{
"nickname":"DD", //这里是昵称
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module DD-Go
module DDatHome-go

go 1.13
go 1.14

require (
github.com/kardianos/service v1.0.0
github.com/stretchr/testify v1.5.1 // indirect
github.com/tidwall/gjson v1.6.0
golang.org/x/net v0.0.0-20200513185701-a91f0712d120
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20200513185701-a91f0712d120 h1:EZ3cVSzKOlJxAd8e8YAJ7no8nNypTxexh/YE/xW3ZEY=
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 h1:eDrdRpKgkcCqKZQwyZRyeFZgfqt37SL7Kv3tok06cKE=
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
Expand Down
20 changes: 14 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type GoResult struct {
var (
ddName string = "DD"
interval float64 = 500
version string = "1.0.0"
version string = "1.0.1"
ws *websocket.Conn
)

Expand Down Expand Up @@ -70,8 +70,9 @@ func (p *program) run() {
_, err := ws.Write([]byte("DDhttp"))
if err != nil {
_ = ws.Close()
if err := connect(); err != nil {
panic(err)
for connect() != nil {
_ = ws.Close()
time.Sleep(time.Millisecond * time.Duration(500))
}
fmt.Println("reconnect success.")
continue
Expand All @@ -90,8 +91,16 @@ func (p *program) run() {
if err != nil {
res.Error = err.Error()
}
json, _ := json.Marshal(res)
_, _ = ws.Write(json)
json, err := json.Marshal(res)
if err != nil {
fmt.Println("json error:", err)
continue
}
_, err = ws.Write(json)
if err != nil {
fmt.Println("error to write websocket:", err)
continue
}
}
}

Expand All @@ -110,7 +119,6 @@ func main() {
if err != nil {
fmt.Println(err)
}

if err != nil {
fmt.Println(err)
}
Expand Down

0 comments on commit b9d1884

Please sign in to comment.