server-go/socket/client-conn-handler.go
2018-04-09 21:11:52 +09:00

46 lines
899 B
Go

package socket
import (
"time"
"git.loafle.net/commons/server-go"
)
type ClientConnHandler interface {
server.ConnectionHandler
GetReconnectInterval() time.Duration
GetReconnectTryTime() int
}
type ClientConnHandlers struct {
server.ConnectionHandlers
ReconnectInterval time.Duration `json:"reconnectInterval"`
ReconnectTryTime int `json:"reconnectTryTime"`
}
func (cch *ClientConnHandlers) GetReconnectInterval() time.Duration {
return cch.ReconnectInterval
}
func (cch *ClientConnHandlers) GetReconnectTryTime() int {
return cch.ReconnectTryTime
}
func (cch *ClientConnHandlers) Validate() error {
if err := cch.ConnectionHandlers.Validate(); nil != err {
return err
}
if cch.ReconnectInterval <= 0 {
cch.ReconnectInterval = server.DefaultReconnectInterval
}
if cch.ReconnectTryTime <= 0 {
cch.ReconnectTryTime = server.DefaultReconnectTryTime
}
return nil
}