overflow_probes/client/probe/socket_handlers.go
crusader ca25ad0f57 ing
2017-12-02 12:13:08 +09:00

42 lines
1.1 KiB
Go

package probe
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"
oopar "git.loafle.net/overflow/overflow_probes/auth/rpc"
)
type SocketHandlers struct {
cwfc.SocketHandlers
napService *oopar.NoAuthProbeService
}
func (sh *SocketHandlers) OnConnect(socketContext cwfc.SocketContext, res *http.Response) {
logging.Logger().Info(fmt.Sprintf("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().Info(fmt.Sprintf("Auth: client has been disconnected soc[%v]", soc))
}
func newSocketHandler(napService *oopar.NoAuthProbeService) cwfc.SocketHandler {
return &SocketHandlers{
napService: napService,
}
}