overflow_probes/auth/client/socket_handlers.go

42 lines
1.1 KiB
Go
Raw Normal View History

2017-12-01 13:01:46 +00:00
package client
import (
"fmt"
"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-01 16:14:22 +00:00
oopar "git.loafle.net/overflow/overflow_probes/auth/rpc"
2017-12-01 13:01:46 +00:00
)
type SocketHandlers struct {
cwfc.SocketHandlers
2017-12-01 16:14:22 +00:00
napService *oopar.NoAuthProbeService
2017-12-01 13:01:46 +00:00
}
func (sh *SocketHandlers) OnConnect(socketContext cwfc.SocketContext, res *http.Response) {
logging.Logger().Info(fmt.Sprintf("Auth: client has been connected res[%v]", res))
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) {
logging.Logger().Info(fmt.Sprintf("Auth: client has been disconnected soc[%v]", soc))
}
2017-12-01 16:14:22 +00:00
func newSocketHandler(napService *oopar.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
}
}