overflow_probes/auth/client/socket_handlers.go
crusader 94a4f3136c ing
2018-03-21 19:22:13 +09:00

41 lines
1.1 KiB
Go

package client
import (
"net/http"
"git.loafle.net/commons_go/logging"
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
ooccn "git.loafle.net/overflow/overflow_commons_go/config/noauthprobe"
oocmn "git.loafle.net/overflow/overflow_commons_go/modules/noauthprobe"
oopas "git.loafle.net/overflow/overflow_probes/auth/service"
)
type SocketHandlers struct {
cwfc.SocketHandlers
napService *oopas.NoAuthProbeService
}
func (sh *SocketHandlers) OnConnect(socketContext cwfc.SocketContext, res *http.Response) {
logging.Logger().Infof("Auth: client has been connected res[%v]", res)
switch sh.napService.Config.State() {
case ooccn.NoAuthProbeStateTypeNotRegisterd:
tempProbeKey := res.Header.Get(oocmn.HTTPResponseHeaderKey_NoAuthProbe_SetTempProbeKey)
sh.napService.SetTempProbeKey(tempProbeKey)
case ooccn.NoAuthProbeStateTypeRegisterd:
}
}
func (sh *SocketHandlers) OnDisconnect(soc cwfc.Socket) {
logging.Logger().Infof("Auth: client has been disconnected soc[%v]", soc)
}
func newSocketHandler(napService *oopas.NoAuthProbeService) cwfc.SocketHandler {
return &SocketHandlers{
napService: napService,
}
}