From 92d0dcef6261a216603a9b5351a0b23b3b15ff95 Mon Sep 17 00:00:00 2001 From: liuxiaobo <1224730913@qq.com> Date: Tue, 27 May 2025 00:23:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B6=88=E6=81=AF=E5=88=86?= =?UTF-8?q?=E5=8F=91=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- processor/{ => pb}/internal.pb.go | 2 +- processor/processor_test.go | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) rename processor/{ => pb}/internal.pb.go (99%) diff --git a/processor/internal.pb.go b/processor/pb/internal.pb.go similarity index 99% rename from processor/internal.pb.go rename to processor/pb/internal.pb.go index 6e6eec2..a043c86 100644 --- a/processor/internal.pb.go +++ b/processor/pb/internal.pb.go @@ -4,7 +4,7 @@ // protoc v6.31.0 // source: internal.proto -package processor +package pb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" diff --git a/processor/processor_test.go b/processor/processor_test.go index 88826e4..00e510e 100644 --- a/processor/processor_test.go +++ b/processor/processor_test.go @@ -2,11 +2,12 @@ package processor import ( "fmt" + "github.com/fox/fox/processor/pb" "github.com/golang/protobuf/proto" "testing" ) -func onChat(userId int64, req *InternalMsg) { +func onChat(userId int64, req *pb.InternalMsg) { _ = userId fmt.Println("onChat", string(req.Msg)) } @@ -14,14 +15,14 @@ func onChat(userId int64, req *InternalMsg) { func TestProcessor(t *testing.T) { p := NewProcessor() p.RegisterMessages(RegisterMetas{ - MsgId_Internal: {InternalMsg{}, onChat}, + pb.MsgId_Internal: {pb.InternalMsg{}, onChat}, }) - tmp := &InternalMsg{UserId: 1, ConnId: 1, MsgId: int32(MsgId_Internal), Msg: []byte("hello world")} + tmp := &pb.InternalMsg{UserId: 1, ConnId: 1, MsgId: int32(pb.MsgId_Internal), Msg: []byte("hello world")} data, _ := proto.Marshal(tmp) - req, _ := p.Unmarshal(int32(MsgId_Internal), data) - if err := p.Dispatch(int32(MsgId_Internal), int64(1), req); err != nil { + req, _ := p.Unmarshal(int32(pb.MsgId_Internal), data) + if err := p.Dispatch(int32(pb.MsgId_Internal), int64(1), req); err != nil { t.Error(err) } }