Parcourir la source

调整粘包处理

develop
H Vs il y a 9 mois
Parent
révision
45e13cef87
1 fichiers modifiés avec 2 ajouts et 2 suppressions
  1. +2
    -2
      NearCardAttendance.Service/TcpServer/Handler/ProtocolHandler.cs

+ 2
- 2
NearCardAttendance.Service/TcpServer/Handler/ProtocolHandler.cs Voir le fichier

@@ -110,7 +110,7 @@ namespace NearCardAttendance.Service.TcpServer.Handler
// Console.WriteLine(message); // Console.WriteLine(message);
} }
// 过长且不完整 // 过长且不完整
if (inputString.Length > messageLength)
if (inputString.Length > messagesStringLength)
{ {
var overLongbuffer = Unpooled.Buffer(); var overLongbuffer = Unpooled.Buffer();
overLongbuffer.WriteBytes(Unpooled.WrappedBuffer(Encoding.ASCII.GetBytes(inputString.Substring(messageLength, inputString.Length- messageLength)))); overLongbuffer.WriteBytes(Unpooled.WrappedBuffer(Encoding.ASCII.GetBytes(inputString.Substring(messageLength, inputString.Length- messageLength))));
@@ -118,7 +118,7 @@ namespace NearCardAttendance.Service.TcpServer.Handler
buffer = overLongbuffer; buffer = overLongbuffer;
} }
// 数据完整 // 数据完整
if (inputString.Length ==messageLength)
if (inputString.Length == messagesStringLength)
{ {
ReleaseBuffer(); ReleaseBuffer();
} }


Chargement…
Annuler
Enregistrer