Skip to content

Commit

Permalink
issues #64 fix gate connect
Browse files Browse the repository at this point in the history
  • Loading branch information
alekseyf12 committed Aug 25, 2019
1 parent d06efa2 commit 05bb76d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions system/gate_client/gate_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/e154/smart-home/system/uuid"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
"github.com/jinzhu/copier"
"github.com/op/go-logging"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -65,11 +66,12 @@ func (g *GateClient) Shutdown() {
}

func (g *GateClient) Close() {
log.Info("Close")
g.wsClient.Close()
}

func (g *GateClient) Connect() {

log.Info("Connect")
if !g.settings.Valid() {
return
}
Expand All @@ -78,6 +80,7 @@ func (g *GateClient) Connect() {
}

func (g *GateClient) BroadcastAccessToken() {
log.Info("Broadcast access token")

broadcastMsg := &stream.Message{
Command: "gate.access_token",
Expand All @@ -92,7 +95,7 @@ func (g *GateClient) BroadcastAccessToken() {
}

func (g *GateClient) RegisterServer() {

log.Info("Register server")
if g.settings.GateServerToken != "" {
return
}
Expand Down Expand Up @@ -256,7 +259,9 @@ func (g *GateClient) GetSettings() (*Settings, error) {
}

func (g *GateClient) UpdateSettings(settings *Settings) (err error) {
g.settings = settings
if err = copier.Copy(&g.settings, &settings); err != nil {
return
}
if err = g.SaveSettings(); err != nil {
return
}
Expand Down
3 changes: 3 additions & 0 deletions system/gate_client/ws_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ func (client *WsClient) connect() {
if strings.Contains(err.Error(), "connection refused") {
return
}
if strings.Contains(err.Error(), "bad handshake") {
return
}
log.Debug(err.Error())
}

Expand Down

0 comments on commit 05bb76d

Please sign in to comment.