From c65fd5961b641368e80d04b25eed81f8f8725677 Mon Sep 17 00:00:00 2001 From: NoahLan <6995syu@163.com> Date: Wed, 24 May 2023 10:29:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dtest=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/nnet_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/nnet_test.go b/core/nnet_test.go index 6420c0b..37d629d 100644 --- a/core/nnet_test.go +++ b/core/nnet_test.go @@ -5,7 +5,7 @@ import ( "git.noahlan.cn/noahlan/nnet/config" "git.noahlan.cn/noahlan/nnet/entity" "git.noahlan.cn/noahlan/nnet/packet" - "git.noahlan.cn/noahlan/nnet/protocol" + "git.noahlan.cn/noahlan/nnet/protocol/nnet" "git.noahlan.cn/noahlan/ntools-go/core/nlog" "git.noahlan.cn/noahlan/ntools-go/core/pool" "math" @@ -29,19 +29,19 @@ func TestServer(t *testing.T) { Nonblocking: false, DisablePurge: false, }, - }, protocol.WithNNetProtocol(protocol.NNetConfig{ + }, nnet.WithNNetProtocol(nnet.Config{ HeartbeatInterval: 0, HandshakeValidator: nil, })...) server.AddRoute(Route{ - Matches: protocol.Match{ + Matches: nnet.Match{ Route: "test", Code: 1, }, Handler: func(entity entity.NetworkEntity, pkg packet.IPacket) { fmt.Println(pkg) - p, ok := pkg.(*protocol.NNetPacket) + p, ok := pkg.(*nnet.Packet) if !ok { nlog.Error("wrong packet type") return @@ -49,11 +49,11 @@ func TestServer(t *testing.T) { bd := []byte("服务器接收到数据为: " + string(p.GetBody())) // 注:Response类型数据不需要Route(原地返回,客户端需等待) - _ = entity.Send(protocol.Header{ - PacketType: protocol.Data, + _ = entity.Send(nnet.Header{ + PacketType: nnet.Data, Length: uint32(len(bd)), - MessageHeader: protocol.MessageHeader{ - MsgType: protocol.Response, + MessageHeader: nnet.MessageHeader{ + MsgType: nnet.Response, ID: p.ID, Route: p.Route, },