This commit is contained in:
crusader 2018-03-19 16:19:34 +09:00
parent 74b55942b9
commit 4c8bb08e99
2 changed files with 16 additions and 8 deletions

View File

@ -9,6 +9,8 @@ import (
var ( var (
ServletSocketKey = cuc.ContextKey("ServletSocket") ServletSocketKey = cuc.ContextKey("ServletSocket")
GRPCMetadataKey = cuc.ContextKey("GRPCMetadata")
ClientTypeKey = cuc.ContextKey("ClientType") ClientTypeKey = cuc.ContextKey("ClientType")
SocketIDKey = cuc.ContextKey("SocketID") SocketIDKey = cuc.ContextKey("SocketID")
TargetIDKey = cuc.ContextKey("TargetID") TargetIDKey = cuc.ContextKey("TargetID")

View File

@ -24,11 +24,17 @@ type GatewayRPCServletHandlers struct {
} }
func (sh *GatewayRPCServletHandlers) Invoke(servletCTX rpc.ServletContext, requestCodec protocol.RegistryCodec) (result interface{}, err error) { func (sh *GatewayRPCServletHandlers) Invoke(servletCTX rpc.ServletContext, requestCodec protocol.RegistryCodec) (result interface{}, err error) {
md := metadata.Pairs( md := servletCTX.GetAttribute(oogw.GRPCMetadataKey)
if nil == md {
md = metadata.Pairs(
oogw.GRPCClientTypeKey, servletCTX.GetAttribute(oogw.SocketIDKey).(string), oogw.GRPCClientTypeKey, servletCTX.GetAttribute(oogw.SocketIDKey).(string),
oogw.GRPCSessionIDKey, servletCTX.GetAttribute(oogw.SocketIDKey).(string), oogw.GRPCSessionIDKey, servletCTX.GetAttribute(oogw.SocketIDKey).(string),
oogw.GRPCTargetIDKey, servletCTX.GetAttribute(oogw.SocketIDKey).(string)) oogw.GRPCTargetIDKey, servletCTX.GetAttribute(oogw.SocketIDKey).(string))
grpcCTX := metadata.NewOutgoingContext(context.Background(), md)
servletCTX.SetAttribute(oogw.GRPCMetadataKey, md)
}
grpcCTX := metadata.NewOutgoingContext(context.Background(), md.(metadata.MD))
params, err := requestCodec.Params() params, err := requestCodec.Params()
if nil != err { if nil != err {