ing
This commit is contained in:
parent
7b033878f0
commit
258d739f17
|
@ -1,6 +1,7 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
cwf "git.loafle.net/commons_go/websocket_fasthttp"
|
||||||
oogws "git.loafle.net/overflow/overflow_gateway_websocket/server"
|
oogws "git.loafle.net/overflow/overflow_gateway_websocket/server"
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
)
|
)
|
||||||
|
@ -17,16 +18,16 @@ type ServerHandlers struct {
|
||||||
|
|
||||||
// Init invoked before the server is started
|
// Init invoked before the server is started
|
||||||
// If you override ths method, must call
|
// If you override ths method, must call
|
||||||
func (sh *ServerHandlers) Init() error {
|
func (sh *ServerHandlers) Init(serverCTX cwf.ServerContext) error {
|
||||||
if err := sh.ServerHandler.Init(); nil != err {
|
if err := sh.ServerHandler.Init(serverCTX); nil != err {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *ServerHandlers) OnStart() {
|
func (sh *ServerHandlers) OnStart(serverCTX cwf.ServerContext) {
|
||||||
sh.ServerHandler.OnStart()
|
sh.ServerHandler.OnStart(serverCTX)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,9 +42,9 @@ func (sh *ServerHandlers) CheckOrigin(ctx *fasthttp.RequestCtx) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *ServerHandlers) OnStop() {
|
func (sh *ServerHandlers) OnStop(serverCTX cwf.ServerContext) {
|
||||||
|
|
||||||
sh.ServerHandler.OnStop()
|
sh.ServerHandler.OnStop(serverCTX)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *ServerHandlers) Validate() {
|
func (sh *ServerHandlers) Validate() {
|
||||||
|
|
|
@ -23,7 +23,7 @@ func ServletInit(sh oogws.ServerHandler) {
|
||||||
logging.Logger().Panic(fmt.Sprintf("Webapp: config of servlet[%s] is not exist", Name))
|
logging.Logger().Panic(fmt.Sprintf("Webapp: config of servlet[%s] is not exist", Name))
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcGH := newRPCGatewayHandler()
|
rpcGH := newGatewayRPCHandler()
|
||||||
sh.RegisterRPCGatewayServlet(Name, rpcGH)
|
sh.RegisterRPCGatewayServlet(Name, rpcGH)
|
||||||
|
|
||||||
//sub := newSubscriberHandler(rpcSH)
|
//sub := newSubscriberHandler(rpcSH)
|
||||||
|
@ -31,7 +31,6 @@ func ServletInit(sh oogws.ServerHandler) {
|
||||||
//sh.RegisterSubscriber(sub)
|
//sh.RegisterSubscriber(sub)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func ServletDestroy() {
|
func ServletDestroy() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,27 +4,28 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.loafle.net/commons_go/logging"
|
"git.loafle.net/commons_go/logging"
|
||||||
|
cwf "git.loafle.net/commons_go/websocket_fasthttp"
|
||||||
"git.loafle.net/overflow/overflow_gateway_websocket/config"
|
"git.loafle.net/overflow/overflow_gateway_websocket/config"
|
||||||
"git.loafle.net/overflow/overflow_gateway_websocket/rpc"
|
"git.loafle.net/overflow/overflow_gateway_websocket/rpc"
|
||||||
jwt "github.com/dgrijalva/jwt-go"
|
jwt "github.com/dgrijalva/jwt-go"
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newRPCGatewayHandler() rpc.RPCGatewayHandler {
|
func newGatewayRPCHandler() rpc.GatewayRPCHandler {
|
||||||
gh := &RPCGatewayHandlers{}
|
gh := &GatewayRPCHandlers{}
|
||||||
|
|
||||||
return gh
|
return gh
|
||||||
}
|
}
|
||||||
|
|
||||||
type RPCGatewayHandlers struct {
|
type GatewayRPCHandlers struct {
|
||||||
rpc.RPCGatewayHandlers
|
rpc.GatewayRPCHandlers
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *RPCGatewayHandlers) Init() error {
|
func (sh *GatewayRPCHandlers) Init(serverCTX cwf.ServerContext) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *RPCGatewayHandlers) Handshake(ctx *fasthttp.RequestCtx) (id string, extensionsHeader *fasthttp.ResponseHeader) {
|
func (sh *GatewayRPCHandlers) Handshake(serverCTX cwf.ServerContext, ctx *fasthttp.RequestCtx) (id string, extensionsHeader *fasthttp.ResponseHeader) {
|
||||||
var ok bool
|
var ok bool
|
||||||
// tokenString := string(soc.Conn().Headers().Cookie("AuthToken"))
|
// tokenString := string(soc.Conn().Headers().Cookie("AuthToken"))
|
||||||
tokenString := "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvdmVyRmxvdyIsImlhdCI6MTUwNDU5NTExOSwiZXhwIjoxNTM2MTMxMTE5LCJhdWQiOiJ3d3cub3ZlcmZsb3cuY2xvdWQiLCJzdWIiOiJvdmVyZmxvd0Bsb2FmbGUuY29tIn0.-WQi3OykPlJ9x8RcZGhWXEtGw4GhU6wmyJ_AWh2rMeUatQylfPzvmum2Xfp6pwKLMmcP76XoDPNyq06i7RKWNQ"
|
tokenString := "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvdmVyRmxvdyIsImlhdCI6MTUwNDU5NTExOSwiZXhwIjoxNTM2MTMxMTE5LCJhdWQiOiJ3d3cub3ZlcmZsb3cuY2xvdWQiLCJzdWIiOiJvdmVyZmxvd0Bsb2FmbGUuY29tIn0.-WQi3OykPlJ9x8RcZGhWXEtGw4GhU6wmyJ_AWh2rMeUatQylfPzvmum2Xfp6pwKLMmcP76XoDPNyq06i7RKWNQ"
|
||||||
|
@ -51,6 +52,6 @@ func (sh *RPCGatewayHandlers) Handshake(ctx *fasthttp.RequestCtx) (id string, ex
|
||||||
return claims["sub"].(string), nil
|
return claims["sub"].(string), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *RPCGatewayHandlers) Validate() {
|
func (sh *GatewayRPCHandlers) Validate() {
|
||||||
sh.RPCGatewayHandlers.Validate()
|
sh.GatewayRPCHandlers.Validate()
|
||||||
}
|
}
|
|
@ -4,27 +4,28 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.loafle.net/commons_go/logging"
|
"git.loafle.net/commons_go/logging"
|
||||||
|
cwf "git.loafle.net/commons_go/websocket_fasthttp"
|
||||||
"git.loafle.net/overflow/overflow_gateway_websocket/config"
|
"git.loafle.net/overflow/overflow_gateway_websocket/config"
|
||||||
"git.loafle.net/overflow/overflow_gateway_websocket/rpc"
|
"git.loafle.net/overflow/overflow_gateway_websocket/rpc"
|
||||||
jwt "github.com/dgrijalva/jwt-go"
|
jwt "github.com/dgrijalva/jwt-go"
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newRPCGatewayHandler() rpc.RPCGatewayHandler {
|
func newGatewayRPCHandler() rpc.GatewayRPCHandler {
|
||||||
gh := &RPCGatewayHandlers{}
|
gh := &GatewayRPCHandlers{}
|
||||||
|
|
||||||
return gh
|
return gh
|
||||||
}
|
}
|
||||||
|
|
||||||
type RPCGatewayHandlers struct {
|
type GatewayRPCHandlers struct {
|
||||||
rpc.RPCGatewayHandlers
|
rpc.GatewayRPCHandlers
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *RPCGatewayHandlers) Init() error {
|
func (sh *GatewayRPCHandlers) Init(serverCTX cwf.ServerContext) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *RPCGatewayHandlers) Handshake(ctx *fasthttp.RequestCtx) (id string, extensionsHeader *fasthttp.ResponseHeader) {
|
func (sh *GatewayRPCHandlers) Handshake(serverCTX cwf.ServerContext, ctx *fasthttp.RequestCtx) (id string, extensionsHeader *fasthttp.ResponseHeader) {
|
||||||
var ok bool
|
var ok bool
|
||||||
// tokenString := string(soc.Conn().Headers().Cookie("AuthToken"))
|
// tokenString := string(soc.Conn().Headers().Cookie("AuthToken"))
|
||||||
tokenString := "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvdmVyRmxvdyIsImlhdCI6MTUwNDU5NTExOSwiZXhwIjoxNTM2MTMxMTE5LCJhdWQiOiJ3d3cub3ZlcmZsb3cuY2xvdWQiLCJzdWIiOiJvdmVyZmxvd0Bsb2FmbGUuY29tIn0.-WQi3OykPlJ9x8RcZGhWXEtGw4GhU6wmyJ_AWh2rMeUatQylfPzvmum2Xfp6pwKLMmcP76XoDPNyq06i7RKWNQ"
|
tokenString := "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvdmVyRmxvdyIsImlhdCI6MTUwNDU5NTExOSwiZXhwIjoxNTM2MTMxMTE5LCJhdWQiOiJ3d3cub3ZlcmZsb3cuY2xvdWQiLCJzdWIiOiJvdmVyZmxvd0Bsb2FmbGUuY29tIn0.-WQi3OykPlJ9x8RcZGhWXEtGw4GhU6wmyJ_AWh2rMeUatQylfPzvmum2Xfp6pwKLMmcP76XoDPNyq06i7RKWNQ"
|
||||||
|
@ -51,6 +52,6 @@ func (sh *RPCGatewayHandlers) Handshake(ctx *fasthttp.RequestCtx) (id string, ex
|
||||||
return claims["sub"].(string), nil
|
return claims["sub"].(string), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *RPCGatewayHandlers) Validate() {
|
func (sh *GatewayRPCHandlers) Validate() {
|
||||||
sh.RPCGatewayHandlers.Validate()
|
sh.GatewayRPCHandlers.Validate()
|
||||||
}
|
}
|
|
@ -23,14 +23,13 @@ func ServletInit(sh oogws.ServerHandler) {
|
||||||
logging.Logger().Panic(fmt.Sprintf("Webapp: config of servlet[%s] is not exist", Name))
|
logging.Logger().Panic(fmt.Sprintf("Webapp: config of servlet[%s] is not exist", Name))
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcGH := newRPCGatewayHandler()
|
rpcGH := newGatewayRPCHandler()
|
||||||
rpcSH := sh.RegisterRPCGatewayServlet(Name, rpcGH)
|
rpcSH := sh.RegisterRPCGatewayServlet(Name, rpcGH)
|
||||||
sub := newSubscriberHandler(rpcSH)
|
sub := newSubscriberHandler(rpcSH)
|
||||||
|
|
||||||
sh.RegisterSubscriber(sub)
|
sh.RegisterSubscriber(sub)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func ServletDestroy() {
|
func ServletDestroy() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,27 +4,28 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.loafle.net/commons_go/logging"
|
"git.loafle.net/commons_go/logging"
|
||||||
|
cwf "git.loafle.net/commons_go/websocket_fasthttp"
|
||||||
"git.loafle.net/overflow/overflow_gateway_websocket/config"
|
"git.loafle.net/overflow/overflow_gateway_websocket/config"
|
||||||
"git.loafle.net/overflow/overflow_gateway_websocket/rpc"
|
"git.loafle.net/overflow/overflow_gateway_websocket/rpc"
|
||||||
jwt "github.com/dgrijalva/jwt-go"
|
jwt "github.com/dgrijalva/jwt-go"
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newRPCGatewayHandler() rpc.RPCGatewayHandler {
|
func newGatewayRPCHandler() rpc.GatewayRPCHandler {
|
||||||
gh := &RPCGatewayHandlers{}
|
gh := &GatewayRPCHandlers{}
|
||||||
|
|
||||||
return gh
|
return gh
|
||||||
}
|
}
|
||||||
|
|
||||||
type RPCGatewayHandlers struct {
|
type GatewayRPCHandlers struct {
|
||||||
rpc.RPCGatewayHandlers
|
rpc.GatewayRPCHandlers
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *RPCGatewayHandlers) Init() error {
|
func (sh *GatewayRPCHandlers) Init(serverCTX cwf.ServerContext) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *RPCGatewayHandlers) Handshake(ctx *fasthttp.RequestCtx) (id string, extensionsHeader *fasthttp.ResponseHeader) {
|
func (sh *GatewayRPCHandlers) Handshake(serverCTX cwf.ServerContext, ctx *fasthttp.RequestCtx) (id string, extensionsHeader *fasthttp.ResponseHeader) {
|
||||||
var ok bool
|
var ok bool
|
||||||
// tokenString := string(soc.Conn().Headers().Cookie("AuthToken"))
|
// tokenString := string(soc.Conn().Headers().Cookie("AuthToken"))
|
||||||
tokenString := "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvdmVyRmxvdyIsImlhdCI6MTUwNDU5NTExOSwiZXhwIjoxNTM2MTMxMTE5LCJhdWQiOiJ3d3cub3ZlcmZsb3cuY2xvdWQiLCJzdWIiOiJvdmVyZmxvd0Bsb2FmbGUuY29tIn0.-WQi3OykPlJ9x8RcZGhWXEtGw4GhU6wmyJ_AWh2rMeUatQylfPzvmum2Xfp6pwKLMmcP76XoDPNyq06i7RKWNQ"
|
tokenString := "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvdmVyRmxvdyIsImlhdCI6MTUwNDU5NTExOSwiZXhwIjoxNTM2MTMxMTE5LCJhdWQiOiJ3d3cub3ZlcmZsb3cuY2xvdWQiLCJzdWIiOiJvdmVyZmxvd0Bsb2FmbGUuY29tIn0.-WQi3OykPlJ9x8RcZGhWXEtGw4GhU6wmyJ_AWh2rMeUatQylfPzvmum2Xfp6pwKLMmcP76XoDPNyq06i7RKWNQ"
|
||||||
|
@ -51,6 +52,6 @@ func (sh *RPCGatewayHandlers) Handshake(ctx *fasthttp.RequestCtx) (id string, ex
|
||||||
return claims["sub"].(string), nil
|
return claims["sub"].(string), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *RPCGatewayHandlers) Validate() {
|
func (sh *GatewayRPCHandlers) Validate() {
|
||||||
sh.RPCGatewayHandlers.Validate()
|
sh.GatewayRPCHandlers.Validate()
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package probe
|
package probe
|
||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
@ -24,14 +23,13 @@ func ServletInit(sh oogws.ServerHandler) {
|
||||||
logging.Logger().Panic(fmt.Sprintf("Webapp: config of servlet[%s] is not exist", Name))
|
logging.Logger().Panic(fmt.Sprintf("Webapp: config of servlet[%s] is not exist", Name))
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcGH := newRPCGatewayHandler()
|
rpcGH := newGatewayRPCHandler()
|
||||||
rpcSH := sh.RegisterRPCGatewayServlet(Name, rpcGH)
|
rpcSH := sh.RegisterRPCGatewayServlet(Name, rpcGH)
|
||||||
sub := newSubscriberHandler(rpcSH)
|
sub := newSubscriberHandler(rpcSH)
|
||||||
|
|
||||||
sh.RegisterSubscriber(sub)
|
sh.RegisterSubscriber(sub)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func ServletDestroy() {
|
func ServletDestroy() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user