ing
This commit is contained in:
11
client/file/client.go
Normal file
11
client/file/client.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
||||
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
||||
)
|
||||
|
||||
func NewClient(ch oogwc.ClientHandler, sb cwfc.SocketBuilder) oogwc.Client {
|
||||
|
||||
return oogwc.New(ch, sb)
|
||||
}
|
||||
31
client/file/client_handlers.go
Normal file
31
client/file/client_handlers.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.loafle.net/commons_go/logging"
|
||||
crc "git.loafle.net/commons_go/rpc/client"
|
||||
crr "git.loafle.net/commons_go/rpc/registry"
|
||||
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/client"
|
||||
)
|
||||
|
||||
func NewClientHandler(rpcInvoker crr.RPCInvoker) oogwc.ClientHandler {
|
||||
ch := &ClientHandlers{}
|
||||
ch.ClientHandler = oogwc.NewClientHandler(rpcInvoker)
|
||||
|
||||
return ch
|
||||
}
|
||||
|
||||
type ClientHandlers struct {
|
||||
oogwc.ClientHandler
|
||||
}
|
||||
|
||||
func (ch *ClientHandlers) Init(clientCTX crc.ClientContext) error {
|
||||
logging.Logger().Info(fmt.Sprintf("Probe: client has been initialized"))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ch *ClientHandlers) Destroy(clientCTX crc.ClientContext) {
|
||||
logging.Logger().Info(fmt.Sprintf("Probe: client has been destroyed"))
|
||||
}
|
||||
51
client/file/socket_builders.go
Normal file
51
client/file/socket_builders.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.loafle.net/commons_go/logging"
|
||||
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
||||
oocmn "git.loafle.net/overflow/overflow_commons_go/modules/noauthprobe"
|
||||
oopar "git.loafle.net/overflow/overflow_probes/auth/rpc"
|
||||
oopcc "git.loafle.net/overflow/overflow_probes/central/client"
|
||||
)
|
||||
|
||||
func NewSocketBuilder(napService *oopar.NoAuthProbeService) cwfc.SocketBuilder {
|
||||
sb := &SocketBuilders{
|
||||
napService: napService,
|
||||
}
|
||||
sb.SocketBuilders = oopcc.NewSocketBuilder(oocmn.HTTPEntry_NoAuthProbe)
|
||||
if nil == sb.SocketBuilders {
|
||||
return nil
|
||||
}
|
||||
|
||||
return sb
|
||||
}
|
||||
|
||||
type SocketBuilders struct {
|
||||
*oopcc.SocketBuilders
|
||||
|
||||
napService *oopar.NoAuthProbeService
|
||||
}
|
||||
|
||||
func (sb *SocketBuilders) SocketHandler() cwfc.SocketHandler {
|
||||
return newSocketHandler(sb.napService)
|
||||
}
|
||||
|
||||
func (sb *SocketBuilders) GetRequestHeader() http.Header {
|
||||
h := sb.napService.GetRequestHeader()
|
||||
header := http.Header{}
|
||||
for k, v := range h {
|
||||
header[k] = v
|
||||
}
|
||||
|
||||
return header
|
||||
}
|
||||
|
||||
func (sb *SocketBuilders) Validate() {
|
||||
sb.SocketBuilders.Validate()
|
||||
|
||||
if nil == sb.napService {
|
||||
logging.Logger().Panic("Auth: NoAuthProbeService must be specified")
|
||||
}
|
||||
}
|
||||
41
client/file/socket_handlers.go
Normal file
41
client/file/socket_handlers.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package file
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user