This commit is contained in:
crusader 2018-07-03 14:58:52 +09:00
parent 39d7640d8b
commit a9a6e238c7

View File

@ -110,10 +110,13 @@ func (s *ContainerServlets) Handle(servletCtx server.ServletCtx,
}()
var (
src crp.ServerRequestCodec
result interface{}
replyBuff []byte
err error
src crp.ServerRequestCodec
messageType int
message []byte
result interface{}
resMessageType int
resMessage []byte
err error
)
if nil != _containerType {
@ -130,8 +133,9 @@ func (s *ContainerServlets) Handle(servletCtx server.ServletCtx,
if !ok {
return
}
messageType, message = socketMessage()
// grpc exec method call
src, err = s.RPCServerCodec.NewRequest(msg)
src, err = s.RPCServerCodec.NewRequest(messageType, message)
if nil != err {
logging.Logger().Error(err)
break
@ -151,21 +155,21 @@ func (s *ContainerServlets) Handle(servletCtx server.ServletCtx,
if !src.HasResponse() {
break
}
replyBuff, err = src.NewResponse(result, err)
resMessageType, resMessage, err = src.NewResponse(result, err)
if nil != err {
logging.Logger().Error(err)
s.writeError(src, writeChan, crp.E_INTERNAL, "", err)
break
}
writeChan <- replyBuff
writeChan <- css.MakeSocketMessage(resMessageType, resMessage)
case <-stopChan:
return
}
}
}
func (s *ContainerServlets) writeError(src crp.ServerRequestCodec, writeChan chan<- []byte, code crp.ErrorCode, message string, data interface{}) {
func (s *ContainerServlets) writeError(src crp.ServerRequestCodec, writeChan chan<- css.SocketMessage, code crp.ErrorCode, message string, data interface{}) {
if !src.HasResponse() {
return
}
@ -176,10 +180,10 @@ func (s *ContainerServlets) writeError(src crp.ServerRequestCodec, writeChan cha
Data: data,
}
buf, err := src.NewResponse(nil, pErr)
messageType, resMessage, err := src.NewResponse(nil, pErr)
if nil != err {
logging.Logger().Error(err)
return
}
writeChan <- buf
writeChan <- css.MakeSocketMessage(messageType, resMessage)
}