sruehl commented on code in PR #1007:
URL: https://github.com/apache/plc4x/pull/1007#discussion_r1485921127


##########
plc4go/internal/opcua/SecureChannel.go:
##########
@@ -234,15 +233,15 @@ func (s *SecureChannel) submit(ctx context.Context, codec 
*MessageCodec, errorDi
                                        s.log.Debug().Type("type", 
message).Msg("Not relevant")
                                        return false
                                }
-                               if requestId := opcuaResponse.GetRequestId(); 
requestId != transactionId {
+                               if requestId := 
opcuaResponse.GetMessage().GetSequenceHeader().GetRequestId(); requestId != 
transactionId {
                                        s.log.Debug().Int32("requestId", 
requestId).Int32("transactionId", transactionId).Msg("Not relevant")
                                        return false
                                } else {
-                                       messageBuffer = 
opcuaResponse.GetMessage()
-                                       if !(s.senderSequenceNumber.Add(1) == 
(opcuaResponse.GetSequenceNumber())) {
+                                       messageBuffer = 
opcuaResponse.(readWriteModel.BinaryPayload).GetPayload()

Review Comment:
   is it ensured that this is always `readWriteModel.BinaryPayloadExactly`?. 
Otherwise this part will panic



##########
plc4go/internal/opcua/SecureChannel.go:
##########
@@ -1034,13 +1044,13 @@ func (s *SecureChannel) onDiscoverOpenSecureChannel(ctx 
context.Context, codec *
                                        s.log.Debug().Type("type", 
messagePDU).Msg("Not relevant")
                                        return false
                                }
-                               return openResponse.GetRequestId() == 
transactionId
+                               return 
openResponse.GetMessage().GetSequenceHeader().GetRequestId() == transactionId
                        },
                        func(message spi.Message) error {
                                opcuaAPU := message.(readWriteModel.OpcuaAPU)
                                messagePDU := opcuaAPU.GetMessage()
                                opcuaOpenResponse := 
messagePDU.(readWriteModel.OpcuaOpenResponse)
-                               readBuffer := 
utils.NewReadBufferByteBased(opcuaOpenResponse.GetMessage(), 
utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian))
+                               readBuffer := 
utils.NewReadBufferByteBased(opcuaOpenResponse.(readWriteModel.BinaryPayloadExactly).GetPayload(),
 utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian))

Review Comment:
   is it ensured that this is always `readWriteModel.BinaryPayloadExactly`?. 
Otherwise this part will panic



##########
plc4go/internal/opcua/EncryptionHandler.go:
##########
@@ -131,9 +131,9 @@ func (h *EncryptionHandler) decodeMessage(ctx 
context.Context, pdu readWriteMode
                var message []byte
                switch pduMessage := pdu.GetMessage().(type) {
                case readWriteModel.OpcuaOpenResponseExactly:
-                       message = pduMessage.GetMessage()
+                       message = 
pduMessage.(readWriteModel.BinaryPayloadExactly).GetPayload()

Review Comment:
   is it ensured that this is always `readWriteModel.BinaryPayloadExactly`?. 
Otherwise this part will panic



##########
plc4go/internal/opcua/EncryptionHandler.go:
##########
@@ -131,9 +131,9 @@ func (h *EncryptionHandler) decodeMessage(ctx 
context.Context, pdu readWriteMode
                var message []byte
                switch pduMessage := pdu.GetMessage().(type) {
                case readWriteModel.OpcuaOpenResponseExactly:
-                       message = pduMessage.GetMessage()
+                       message = 
pduMessage.(readWriteModel.BinaryPayloadExactly).GetPayload()
                case readWriteModel.OpcuaMessageResponseExactly:
-                       message = pduMessage.GetMessage()
+                       message = 
pduMessage.(readWriteModel.BinaryPayloadExactly).GetPayload()

Review Comment:
   is it ensured that this is always `readWriteModel.BinaryPayloadExactly`?. 
Otherwise this part will panic



##########
plc4go/internal/opcua/SecureChannel.go:
##########
@@ -1416,13 +1438,13 @@ func (s *SecureChannel) keepAlive() {
                                                        
s.log.Debug().Type("type", messagePDU).Msg("Not relevant")
                                                        return false
                                                }
-                                               return 
openResponse.GetRequestId() == transactionId
+                                               return 
openResponse.GetMessage().GetSequenceHeader().GetRequestId() == transactionId
                                        },
                                        func(message spi.Message) error {
                                                opcuaAPU := 
message.(readWriteModel.OpcuaAPU)
                                                messagePDU := 
opcuaAPU.GetMessage()
                                                opcuaOpenResponse := 
messagePDU.(readWriteModel.OpcuaOpenResponse)
-                                               readBuffer := 
utils.NewReadBufferByteBased(opcuaOpenResponse.GetMessage(), 
utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian))
+                                               readBuffer := 
utils.NewReadBufferByteBased(opcuaOpenResponse.(readWriteModel.BinaryPayloadExactly).GetPayload(),
 utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian))

Review Comment:
   is it ensured that this is always `readWriteModel.BinaryPayloadExactly`?. 
Otherwise this part will panic



##########
plc4go/internal/opcua/SecureChannel.go:
##########
@@ -1162,13 +1175,13 @@ func (s *SecureChannel) 
onDiscoverGetEndpointsRequest(ctx context.Context, codec
                                        s.log.Debug().Type("type", 
messagePDU).Msg("Not relevant")
                                        return false
                                }
-                               return messageResponse.GetRequestId() == 
transactionId
+                               return 
messageResponse.GetMessage().GetSequenceHeader().GetRequestId() == transactionId
                        },
                        func(message spi.Message) error {
                                opcuaAPU := message.(readWriteModel.OpcuaAPU)
                                messagePDU := opcuaAPU.GetMessage()
                                messageResponse := 
messagePDU.(readWriteModel.OpcuaMessageResponse)
-                               readBuffer := 
utils.NewReadBufferByteBased(messageResponse.GetMessage(), 
utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian))
+                               readBuffer := 
utils.NewReadBufferByteBased(messageResponse.(readWriteModel.BinaryPayloadExactly).GetPayload(),
 utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian))

Review Comment:
   is it ensured that this is always `readWriteModel.BinaryPayloadExactly`?. 
Otherwise this part will panic



##########
plc4go/internal/opcua/SecureChannel.go:
##########
@@ -256,12 +255,12 @@ func (s *SecureChannel) submit(ctx context.Context, codec 
*MessageCodec, errorDi
                                s.log.Trace().Stringer("messagePDU", 
messagePDU).Msg("looking at messagePDU")
                                opcuaResponse := 
messagePDU.(readWriteModel.OpcuaMessageResponse)
                                if opcuaResponse.GetChunk() == (FINAL_CHUNK) {
-                                       
s.tokenId.Store(opcuaResponse.GetSecureTokenId())
-                                       
s.channelId.Store(opcuaResponse.GetSecureChannelId())
+                                       
s.tokenId.Store(opcuaResponse.GetSecurityHeader().GetSecureTokenId())
+                                       
s.channelId.Store(opcuaResponse.GetSecurityHeader().GetSecureChannelId())
 
                                        consumer(messageBuffer)
                                } else {
-                                       s.log.Warn().Str("chunk", 
opcuaResponse.GetChunk()).Msg("Message discarded")
+                                       s.log.Warn().Str("chunk", 
opcuaResponse.GetChunk().PLC4XEnumName()).Msg("Message discarded")

Review Comment:
   I think you can just use `.Stringer("chunk", opcuaResponse.GetChunk())`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to