This commit is contained in:
crusader 2017-11-29 20:46:56 +09:00
parent 7b033878f0
commit 258d739f17
7 changed files with 43 additions and 43 deletions

View File

@ -1,6 +1,7 @@
package server
import (
cwf "git.loafle.net/commons_go/websocket_fasthttp"
oogws "git.loafle.net/overflow/overflow_gateway_websocket/server"
"github.com/valyala/fasthttp"
)
@ -17,16 +18,16 @@ type ServerHandlers struct {
// Init invoked before the server is started
// If you override ths method, must call
func (sh *ServerHandlers) Init() error {
if err := sh.ServerHandler.Init(); nil != err {
func (sh *ServerHandlers) Init(serverCTX cwf.ServerContext) error {
if err := sh.ServerHandler.Init(serverCTX); nil != err {
return err
}
return nil
}
func (sh *ServerHandlers) OnStart() {
sh.ServerHandler.OnStart()
func (sh *ServerHandlers) OnStart(serverCTX cwf.ServerContext) {
sh.ServerHandler.OnStart(serverCTX)
}
@ -41,9 +42,9 @@ func (sh *ServerHandlers) CheckOrigin(ctx *fasthttp.RequestCtx) bool {
return true
}
func (sh *ServerHandlers) OnStop() {
func (sh *ServerHandlers) OnStop(serverCTX cwf.ServerContext) {
sh.ServerHandler.OnStop()
sh.ServerHandler.OnStop(serverCTX)
}
func (sh *ServerHandlers) Validate() {

View File

@ -23,7 +23,7 @@ func ServletInit(sh oogws.ServerHandler) {
logging.Logger().Panic(fmt.Sprintf("Webapp: config of servlet[%s] is not exist", Name))
}
rpcGH := newRPCGatewayHandler()
rpcGH := newGatewayRPCHandler()
sh.RegisterRPCGatewayServlet(Name, rpcGH)
//sub := newSubscriberHandler(rpcSH)
@ -31,7 +31,6 @@ func ServletInit(sh oogws.ServerHandler) {
//sh.RegisterSubscriber(sub)
}
func ServletDestroy() {
}

View File

@ -4,27 +4,28 @@ import (
"fmt"
"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/rpc"
jwt "github.com/dgrijalva/jwt-go"
"github.com/valyala/fasthttp"
)
func newRPCGatewayHandler() rpc.RPCGatewayHandler {
gh := &RPCGatewayHandlers{}
func newGatewayRPCHandler() rpc.GatewayRPCHandler {
gh := &GatewayRPCHandlers{}
return gh
}
type RPCGatewayHandlers struct {
rpc.RPCGatewayHandlers
type GatewayRPCHandlers struct {
rpc.GatewayRPCHandlers
}
func (sh *RPCGatewayHandlers) Init() error {
func (sh *GatewayRPCHandlers) Init(serverCTX cwf.ServerContext) error {
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
// tokenString := string(soc.Conn().Headers().Cookie("AuthToken"))
tokenString := "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvdmVyRmxvdyIsImlhdCI6MTUwNDU5NTExOSwiZXhwIjoxNTM2MTMxMTE5LCJhdWQiOiJ3d3cub3ZlcmZsb3cuY2xvdWQiLCJzdWIiOiJvdmVyZmxvd0Bsb2FmbGUuY29tIn0.-WQi3OykPlJ9x8RcZGhWXEtGw4GhU6wmyJ_AWh2rMeUatQylfPzvmum2Xfp6pwKLMmcP76XoDPNyq06i7RKWNQ"
@ -51,6 +52,6 @@ func (sh *RPCGatewayHandlers) Handshake(ctx *fasthttp.RequestCtx) (id string, ex
return claims["sub"].(string), nil
}
func (sh *RPCGatewayHandlers) Validate() {
sh.RPCGatewayHandlers.Validate()
func (sh *GatewayRPCHandlers) Validate() {
sh.GatewayRPCHandlers.Validate()
}

View File

@ -4,27 +4,28 @@ import (
"fmt"
"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/rpc"
jwt "github.com/dgrijalva/jwt-go"
"github.com/valyala/fasthttp"
)
func newRPCGatewayHandler() rpc.RPCGatewayHandler {
gh := &RPCGatewayHandlers{}
func newGatewayRPCHandler() rpc.GatewayRPCHandler {
gh := &GatewayRPCHandlers{}
return gh
}
type RPCGatewayHandlers struct {
rpc.RPCGatewayHandlers
type GatewayRPCHandlers struct {
rpc.GatewayRPCHandlers
}
func (sh *RPCGatewayHandlers) Init() error {
func (sh *GatewayRPCHandlers) Init(serverCTX cwf.ServerContext) error {
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
// tokenString := string(soc.Conn().Headers().Cookie("AuthToken"))
tokenString := "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvdmVyRmxvdyIsImlhdCI6MTUwNDU5NTExOSwiZXhwIjoxNTM2MTMxMTE5LCJhdWQiOiJ3d3cub3ZlcmZsb3cuY2xvdWQiLCJzdWIiOiJvdmVyZmxvd0Bsb2FmbGUuY29tIn0.-WQi3OykPlJ9x8RcZGhWXEtGw4GhU6wmyJ_AWh2rMeUatQylfPzvmum2Xfp6pwKLMmcP76XoDPNyq06i7RKWNQ"
@ -51,6 +52,6 @@ func (sh *RPCGatewayHandlers) Handshake(ctx *fasthttp.RequestCtx) (id string, ex
return claims["sub"].(string), nil
}
func (sh *RPCGatewayHandlers) Validate() {
sh.RPCGatewayHandlers.Validate()
func (sh *GatewayRPCHandlers) Validate() {
sh.GatewayRPCHandlers.Validate()
}

View File

@ -23,14 +23,13 @@ func ServletInit(sh oogws.ServerHandler) {
logging.Logger().Panic(fmt.Sprintf("Webapp: config of servlet[%s] is not exist", Name))
}
rpcGH := newRPCGatewayHandler()
rpcGH := newGatewayRPCHandler()
rpcSH := sh.RegisterRPCGatewayServlet(Name, rpcGH)
sub := newSubscriberHandler(rpcSH)
sh.RegisterSubscriber(sub)
}
func ServletDestroy() {
}

View File

@ -4,27 +4,28 @@ import (
"fmt"
"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/rpc"
jwt "github.com/dgrijalva/jwt-go"
"github.com/valyala/fasthttp"
)
func newRPCGatewayHandler() rpc.RPCGatewayHandler {
gh := &RPCGatewayHandlers{}
func newGatewayRPCHandler() rpc.GatewayRPCHandler {
gh := &GatewayRPCHandlers{}
return gh
}
type RPCGatewayHandlers struct {
rpc.RPCGatewayHandlers
type GatewayRPCHandlers struct {
rpc.GatewayRPCHandlers
}
func (sh *RPCGatewayHandlers) Init() error {
func (sh *GatewayRPCHandlers) Init(serverCTX cwf.ServerContext) error {
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
// tokenString := string(soc.Conn().Headers().Cookie("AuthToken"))
tokenString := "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvdmVyRmxvdyIsImlhdCI6MTUwNDU5NTExOSwiZXhwIjoxNTM2MTMxMTE5LCJhdWQiOiJ3d3cub3ZlcmZsb3cuY2xvdWQiLCJzdWIiOiJvdmVyZmxvd0Bsb2FmbGUuY29tIn0.-WQi3OykPlJ9x8RcZGhWXEtGw4GhU6wmyJ_AWh2rMeUatQylfPzvmum2Xfp6pwKLMmcP76XoDPNyq06i7RKWNQ"
@ -51,6 +52,6 @@ func (sh *RPCGatewayHandlers) Handshake(ctx *fasthttp.RequestCtx) (id string, ex
return claims["sub"].(string), nil
}
func (sh *RPCGatewayHandlers) Validate() {
sh.RPCGatewayHandlers.Validate()
func (sh *GatewayRPCHandlers) Validate() {
sh.GatewayRPCHandlers.Validate()
}

View File

@ -1,6 +1,5 @@
package probe
import (
"fmt"
@ -24,14 +23,13 @@ func ServletInit(sh oogws.ServerHandler) {
logging.Logger().Panic(fmt.Sprintf("Webapp: config of servlet[%s] is not exist", Name))
}
rpcGH := newRPCGatewayHandler()
rpcGH := newGatewayRPCHandler()
rpcSH := sh.RegisterRPCGatewayServlet(Name, rpcGH)
sub := newSubscriberHandler(rpcSH)
sh.RegisterSubscriber(sub)
}
func ServletDestroy() {
}