diff --git a/NewLife.Remoting/ApiNetServer.cs b/NewLife.Remoting/ApiNetServer.cs
index 7f5836f..3dd3495 100644
--- a/NewLife.Remoting/ApiNetServer.cs
+++ b/NewLife.Remoting/ApiNetServer.cs
@@ -96,10 +96,7 @@ protected override void OnReceive(ReceivedEventArgs e)
{
if (msg.Payload is ArrayPacket ap2 && ap.Buffer == ap2.Buffer)
{
- var ap3 = new ArrayPacket(ap2.Length);
- ap2.GetSpan().CopyTo(ap3.GetSpan());
-
- msg.Payload = ap3;
+ msg.Payload = ap2.Clone();
}
}
diff --git a/NewLife.Remoting/IEncoder.cs b/NewLife.Remoting/IEncoder.cs
index 4e5c266..60fe168 100644
--- a/NewLife.Remoting/IEncoder.cs
+++ b/NewLife.Remoting/IEncoder.cs
@@ -83,7 +83,7 @@ public virtual IOwnerPacket Encode(String action, Int32? code, IPacket? value)
//ms.Seek(8, SeekOrigin.Begin);
var len = 8 + 1 + Encoding.UTF8.GetByteCount(action) + 4 + 4;
- var pk = new ArrayPacket(len);
+ var pk = new OwnerPacket(len);
// 请求:action + args
// 响应:action + code + result
diff --git a/NewLife.Remoting/NewLife.Remoting.csproj b/NewLife.Remoting/NewLife.Remoting.csproj
index 66e5d74..a5f7687 100644
--- a/NewLife.Remoting/NewLife.Remoting.csproj
+++ b/NewLife.Remoting/NewLife.Remoting.csproj
@@ -52,7 +52,7 @@
-
+
diff --git a/Test/Test.csproj b/Test/Test.csproj
index 40fc84b..f77223a 100644
--- a/Test/Test.csproj
+++ b/Test/Test.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/XUnitTest/JsonEncoderTests.cs b/XUnitTest/JsonEncoderTests.cs
index 94e58f5..2b20cb0 100644
--- a/XUnitTest/JsonEncoderTests.cs
+++ b/XUnitTest/JsonEncoderTests.cs
@@ -25,7 +25,7 @@ public void EncodeRequest()
// 简洁请求
{
value = null;
- var pk = (ArrayPacket)encoder.Encode(name, null, value);
+ var pk = (OwnerPacket)encoder.Encode(name, null, value);
Assert.Equal(1 + name.Length, pk.Total);
Assert.Null(pk.Next);
Assert.Equal(8, pk.Offset);
@@ -38,7 +38,7 @@ public void EncodeRequest()
// 简洁请求,带空数据
{
value = new Byte[0];
- var pk = (ArrayPacket)encoder.Encode(name, null, value);
+ var pk = (OwnerPacket)encoder.Encode(name, null, value);
Assert.Equal(1 + name.Length + 4, pk.Total);
Assert.NotNull(pk.Next);
Assert.Equal(value, pk.Next);
@@ -52,15 +52,15 @@ public void EncodeRequest()
// 标准请求,带数据体
{
value = Rand.NextBytes(64);
- var pk = (ArrayPacket)encoder.Encode(name, null, value);
+ var pk = (OwnerPacket)encoder.Encode(name, null, value);
Assert.Equal(1 + name.Length + 4 + value.Count, pk.Total);
Assert.NotNull(pk.Next);
Assert.Equal(value, pk.Next);
Assert.Equal(8, pk.Offset);
// 拷贝一次,拉平。因为SpanReader不支持跨包读取
- pk = (ArrayPacket)pk.ToArray();
- var reader = new SpanReader(pk.GetSpan());
+ var pk2 = (ArrayPacket)pk.ToArray();
+ var reader = new SpanReader(pk2.GetSpan());
Assert.Equal(name, reader.ReadString());
@@ -83,7 +83,7 @@ public void EncodeResponse()
{
// 错误码200等同于0,表示成功
value = null;
- var pk = (ArrayPacket)encoder.Encode(name, 200, value);
+ var pk = (OwnerPacket)encoder.Encode(name, 200, value);
Assert.Equal(1 + name.Length, pk.Total);
Assert.Null(pk.Next);
Assert.Equal(8, pk.Offset);
@@ -96,7 +96,7 @@ public void EncodeResponse()
// 简洁响应,带异常
{
value = new Byte[0];
- var pk = (ArrayPacket)encoder.Encode(name, 500, value);
+ var pk = (OwnerPacket)encoder.Encode(name, 500, value);
Assert.Equal(1 + name.Length + 4 + 4 + value.Count, pk.Total);
Assert.NotNull(pk.Next);
Assert.Equal(value, pk.Next);
@@ -111,15 +111,15 @@ public void EncodeResponse()
// 标准响应,带数据体
{
value = Rand.NextBytes(64);
- var pk = (ArrayPacket)encoder.Encode(name, 0, value);
+ var pk = (OwnerPacket)encoder.Encode(name, 0, value);
Assert.Equal(1 + name.Length + 4 + value.Count, pk.Total);
Assert.NotNull(pk.Next);
Assert.Equal(value, pk.Next);
Assert.Equal(8, pk.Offset);
// 拷贝一次,拉平。因为SpanReader不支持跨包读取
- pk = (ArrayPacket)pk.ToArray();
- var reader = new SpanReader(pk.GetSpan());
+ var pk2 = (ArrayPacket)pk.ToArray();
+ var reader = new SpanReader(pk2.GetSpan());
Assert.Equal(name, reader.ReadString());
// 正常响应不需要错误码,直接写数据体长度
diff --git a/XUnitTest/XUnitTest.csproj b/XUnitTest/XUnitTest.csproj
index f28bcc7..336d530 100644
--- a/XUnitTest/XUnitTest.csproj
+++ b/XUnitTest/XUnitTest.csproj
@@ -12,7 +12,7 @@
-
+