This commit is contained in:
crusader 2018-03-23 01:45:53 +09:00
parent 5f10acb5e9
commit 5b2b7c19e4
2 changed files with 27 additions and 10 deletions

View File

@ -24,6 +24,17 @@ type GatewayRPCServletHandlers struct {
}
func (sh *GatewayRPCServletHandlers) Invoke(servletCTX rpc.ServletContext, requestCodec protocol.RegistryCodec) (result interface{}, err error) {
defer func () {
if nil != err {
logging.Logger().Errorf("Gateway Websocket: Inovke error %v", err)
}
if !requestCodec.HasResponse() {
result = nil
err = nil
}
}
md := servletCTX.GetAttribute(oogw.GRPCMetadataKey)
if nil == md {
md = metadata.Pairs(
@ -36,23 +47,31 @@ func (sh *GatewayRPCServletHandlers) Invoke(servletCTX rpc.ServletContext, reque
grpcCTX := metadata.NewOutgoingContext(context.Background(), md.(metadata.MD))
params, err := requestCodec.Params()
var (
grpcResult string
params []string
)
params, err = requestCodec.Params()
if nil != err {
return nil, err
return
}
r, err := grpc.Exec(grpcCTX, requestCodec.Method(), params)
grpcResult, err = grpc.Exec(grpcCTX, requestCodec.Method(), params)
if err != nil {
return nil, err
return
}
var m interface{}
err = json.Unmarshal([]byte(r), &m)
if !requestCodec.HasResponse() {
return
}
err = json.Unmarshal([]byte(grpcResult), &result)
if err != nil {
return nil, err
return
}
return m, nil
return
}
func (sh *GatewayRPCServletHandlers) Validate() {

View File

@ -70,8 +70,6 @@ func (sh *RPCGatewayServletHandlers) Handle(soc cwf.Socket, stopChan <-chan stru
var err error
rpcServlet := retainRPCServlet(sh.gwRPCSH, sh.rpcRWCSH)
// rpcServlet := cRPC.NewServlet(sh.gwRPCSH, sh.rpcRWCSH)
defer func() {
rpcServlet.Stop()
releaseRPCServlet(rpcServlet)