Browse Source

Merge pull request #196 from xBlaz3kx/feature/ping

Feature: Added connection state check
main
Lane Wagner 5 months ago
committed by GitHub
parent
commit
3431dc6f85
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions
  1. +5
    -0
      connection.go
  2. +8
    -0
      internal/connectionmanager/connection_manager.go

+ 5
- 0
connection.go View File

@ -88,3 +88,8 @@ func (conn *Conn) Close() error {
conn.closeConnectionToManagerCh <- struct{}{}
return conn.connectionManager.Close()
}
// IsClosed returns whether the connection is closed or not
func (conn *Conn) IsClosed() bool {
return conn.connectionManager.IsClosed()
}

+ 8
- 0
internal/connectionmanager/connection_manager.go View File

@ -171,3 +171,11 @@ func (connManager *ConnectionManager) reconnect() error {
connManager.connection = conn
return nil
}
// IsClosed checks if the connection is closed
func (connManager *ConnectionManager) IsClosed() bool {
connManager.connectionMu.Lock()
defer connManager.connectionMu.Unlock()
return connManager.connection.IsClosed()
}

Loading…
Cancel
Save