2018-05-03 06:30:23 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sync/atomic"
|
|
|
|
|
2018-07-01 06:41:35 +00:00
|
|
|
cssc "git.loafle.net/commons/server-go/socket/client"
|
2018-05-03 06:30:23 +00:00
|
|
|
occ "git.loafle.net/overflow/container-go/client"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ClientHandler interface {
|
|
|
|
occ.ClientHandler
|
|
|
|
}
|
|
|
|
|
|
|
|
type ClientHandlers struct {
|
|
|
|
occ.ClientHandlers
|
|
|
|
|
|
|
|
validated atomic.Value
|
|
|
|
}
|
|
|
|
|
2018-07-01 06:41:35 +00:00
|
|
|
func (ch *ClientHandlers) Init(clientCtx cssc.ClientCtx) error {
|
2018-05-03 06:30:23 +00:00
|
|
|
if err := ch.ClientHandlers.Init(clientCtx); nil != err {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-07-01 06:41:35 +00:00
|
|
|
func (ch *ClientHandlers) OnStart(clientCtx cssc.ClientCtx) error {
|
2018-05-03 06:30:23 +00:00
|
|
|
if err := ch.ClientHandlers.OnStart(clientCtx); nil != err {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-07-01 06:41:35 +00:00
|
|
|
func (ch *ClientHandlers) OnStop(clientCtx cssc.ClientCtx) {
|
2018-05-03 06:30:23 +00:00
|
|
|
|
|
|
|
ch.ClientHandlers.OnStop(clientCtx)
|
|
|
|
}
|
|
|
|
|
2018-07-01 06:41:35 +00:00
|
|
|
func (ch *ClientHandlers) Destroy(clientCtx cssc.ClientCtx) {
|
2018-05-03 06:30:23 +00:00
|
|
|
|
|
|
|
ch.ClientHandlers.Destroy(clientCtx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ch *ClientHandlers) Validate() error {
|
|
|
|
if nil != ch.validated.Load() {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
ch.validated.Store(true)
|
|
|
|
|
|
|
|
if err := ch.ClientHandlers.Validate(); nil != err {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|