41 lines
1.1 KiB
Go
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,
|
|
}
|
|
}
|