43 lines
808 B
Go
43 lines
808 B
Go
|
package server
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
type ClientConnectionHandler interface {
|
||
|
ConnectionHandler
|
||
|
GetReconnectInterval() time.Duration
|
||
|
GetReconnectTryTime() int
|
||
|
}
|
||
|
|
||
|
type ClientConnectionHandlers struct {
|
||
|
ConnectionHandlers
|
||
|
|
||
|
ReconnectInterval time.Duration
|
||
|
ReconnectTryTime int
|
||
|
}
|
||
|
|
||
|
func (cch *ClientConnectionHandlers) GetReconnectInterval() time.Duration {
|
||
|
return cch.ReconnectInterval
|
||
|
}
|
||
|
|
||
|
func (cch *ClientConnectionHandlers) GetReconnectTryTime() int {
|
||
|
return cch.ReconnectTryTime
|
||
|
}
|
||
|
|
||
|
func (cch *ClientConnectionHandlers) Validate() error {
|
||
|
if err := cch.ConnectionHandlers.Validate(); nil != err {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
if cch.ReconnectInterval <= 0 {
|
||
|
cch.ReconnectInterval = DefaultReconnectInterval
|
||
|
}
|
||
|
|
||
|
if cch.ReconnectTryTime <= 0 {
|
||
|
cch.ReconnectTryTime = DefaultReconnectTryTime
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|