2
0

add linter

This commit is contained in:
Lucas Löffel
2019-06-07 16:40:12 +02:00
parent f08ee37522
commit 7f509281a8
2 changed files with 19 additions and 8 deletions
+8
View File
@@ -0,0 +1,8 @@
install:
go get -t -v -u ./...
linter:
golangci-lint run --enable-all
test:
make linter
+11 -8
View File
@@ -36,20 +36,20 @@ type RecConn struct {
// Proxy specifies the proxy function for the dialer
// defaults to ProxyFromEnvironment
Proxy func(*http.Request) (*url.URL, error)
// NonVerbose suppress connecting/reconnecting messages.
NonVerbose bool
// SubscribeHandler fires after the connection successfully establish.
SubscribeHandler func() error
// KeepAliveTimeout is an interval for sending ping/pong messages
// disabled if 0
KeepAliveTimeout time.Duration
// NonVerbose suppress connecting/reconnecting messages.
NonVerbose bool
isConnected bool
mu sync.RWMutex
url string
reqHeader http.Header
httpResp *http.Response
dialErr error
isConnected bool
dialer *websocket.Dialer
*websocket.Conn
@@ -249,7 +249,7 @@ func (rc *RecConn) setDefaultDialer(handshakeTimeout time.Duration) {
rc.dialer = &websocket.Dialer{
HandshakeTimeout: handshakeTimeout,
Proxy: rc.Proxy,
Proxy: rc.Proxy,
}
}
@@ -354,13 +354,16 @@ func (rc *RecConn) keepAlive() {
defer ticker.Stop()
for {
if (!rc.IsConnected()) {
continue;
if !rc.IsConnected() {
continue
}
if err := rc.writeControlPingMessage(); err != nil {
log.Println(err)
}
rc.writeControlPingMessage()
<-ticker.C
if time.Now().Sub(keepAliveResponse.getLastResponse()) > rc.getKeepAliveTimeout() {
if time.Since(keepAliveResponse.getLastResponse()) > rc.getKeepAliveTimeout() {
rc.closeAndReconnect()
return
}