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" oopcc "git.loafle.net/overflow/overflow_probes/central/client" ) func NewSocketBuilder(config *ooccn.NoAuthProbeConfig, tempProbeKeyChan chan string, registerRequestHeader string) cwfc.SocketBuilder { sb := &SocketBuilders{ config: config, tempProbeKeyChan: tempProbeKeyChan, registerRequestHeader: registerRequestHeader, } sb.SocketBuilders = oopcc.NewSocketBuilder(oocmn.HTTPEntry_NoAuthProbe) if nil == sb.SocketBuilders { return nil } return sb } type SocketBuilders struct { *oopcc.SocketBuilders config *ooccn.NoAuthProbeConfig tempProbeKeyChan chan string registerRequestHeader string } func (sb *SocketBuilders) SocketHandler() cwfc.SocketHandler { return newSocketHandler(sb.config, sb.tempProbeKeyChan) } func (sb *SocketBuilders) GetRequestHeader() http.Header { reqHeader := http.Header{} switch sb.config.State() { case ooccn.NoAuthProbeStateTypeNotRegisterd: reqHeader[oocmn.HTTPRequestHeaderKey_NoAuthProbe_Method] = []string{oocmn.HTTPRequestHeaderValue_NoAuthProbe_Method_Regist} reqHeader[oocmn.HTTPRequestHeaderKey_NoAuthProbe_Info] = []string{sb.registerRequestHeader} case ooccn.NoAuthProbeStateTypeRegisterd: reqHeader[oocmn.HTTPRequestHeaderKey_NoAuthProbe_Method] = []string{oocmn.HTTPRequestHeaderValue_NoAuthProbe_Method_Connect} reqHeader[oocmn.HTTPRequestHeaderKey_NoAuthProbe_TempProbeKey] = []string{oocmn.HTTPRequestHeaderValue_NoAuthProbe_Method_Connect} } return reqHeader } func (sb *SocketBuilders) Validate() { sb.SocketBuilders.Validate() if nil == sb.config { logging.Logger().Panic("Auth: NoAuthProbeConfig must be specified") } }