2018-05-03 11:24:07 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sync/atomic"
|
|
|
|
|
|
|
|
crc "git.loafle.net/commons/rpc-go/client"
|
2018-07-01 04:09:50 +00:00
|
|
|
cssc "git.loafle.net/commons/server-go/socket/client"
|
2018-05-03 11:24:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type ClientHandler interface {
|
|
|
|
crc.ClientHandler
|
|
|
|
}
|
|
|
|
|
|
|
|
type ClientHandlers struct {
|
|
|
|
crc.ClientHandlers
|
|
|
|
|
|
|
|
validated atomic.Value
|
|
|
|
}
|
|
|
|
|
2018-07-01 04:09:50 +00:00
|
|
|
func (ch *ClientHandlers) Init(clientCtx cssc.ClientCtx) error {
|
2018-05-03 11:24:07 +00:00
|
|
|
if err := ch.ClientHandlers.Init(clientCtx); nil != err {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-07-01 04:09:50 +00:00
|
|
|
func (ch *ClientHandlers) OnStart(clientCtx cssc.ClientCtx) error {
|
2018-05-03 11:24:07 +00:00
|
|
|
if err := ch.ClientHandlers.OnStart(clientCtx); nil != err {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-07-01 04:09:50 +00:00
|
|
|
func (ch *ClientHandlers) OnStop(clientCtx cssc.ClientCtx) {
|
2018-05-03 11:24:07 +00:00
|
|
|
|
|
|
|
ch.ClientHandlers.OnStop(clientCtx)
|
|
|
|
}
|
|
|
|
|
2018-07-01 04:09:50 +00:00
|
|
|
func (ch *ClientHandlers) Destroy(clientCtx cssc.ClientCtx) {
|
2018-05-03 11:24:07 +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
|
|
|
|
}
|