overflow_probes/auth/client/socket_handlers.go

41 lines
1.1 KiB
Go
Raw Permalink Normal View History

2017-12-01 13:01:46 +00:00
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"
2017-12-02 03:13:08 +00:00
oopas "git.loafle.net/overflow/overflow_probes/auth/service"
2017-12-01 13:01:46 +00:00
)
type SocketHandlers struct {
cwfc.SocketHandlers
2017-12-02 03:13:08 +00:00
napService *oopas.NoAuthProbeService
2017-12-01 13:01:46 +00:00
}
func (sh *SocketHandlers) OnConnect(socketContext cwfc.SocketContext, res *http.Response) {
2018-03-21 10:22:13 +00:00
logging.Logger().Infof("Auth: client has been connected res[%v]", res)
2017-12-01 13:01:46 +00:00
2017-12-01 16:14:22 +00:00
switch sh.napService.Config.State() {
2017-12-01 13:01:46 +00:00
case ooccn.NoAuthProbeStateTypeNotRegisterd:
tempProbeKey := res.Header.Get(oocmn.HTTPResponseHeaderKey_NoAuthProbe_SetTempProbeKey)
2017-12-01 16:14:22 +00:00
sh.napService.SetTempProbeKey(tempProbeKey)
2017-12-01 13:01:46 +00:00
case ooccn.NoAuthProbeStateTypeRegisterd:
}
}
func (sh *SocketHandlers) OnDisconnect(soc cwfc.Socket) {
2018-03-21 10:22:13 +00:00
logging.Logger().Infof("Auth: client has been disconnected soc[%v]", soc)
2017-12-01 13:01:46 +00:00
}
2017-12-02 03:13:08 +00:00
func newSocketHandler(napService *oopas.NoAuthProbeService) cwfc.SocketHandler {
2017-12-01 13:01:46 +00:00
return &SocketHandlers{
2017-12-01 16:14:22 +00:00
napService: napService,
2017-12-01 13:01:46 +00:00
}
}