From ef7ee0ab8ea8bea3550882fa6f8b29dece1f54a4 Mon Sep 17 00:00:00 2001 From: boyce <6549168@qq.com> Date: Thu, 25 Dec 2025 14:32:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8D=8F=E8=AE=AE=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E5=99=A8=E5=92=8C=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cluster/cluster.go | 10 ++++++---- network/processor/pbrawprocessor.go | 4 ++-- network/processor/processor.go | 1 - 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cluster/cluster.go b/cluster/cluster.go index 5274ff6..b74d232 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -411,13 +411,13 @@ func GetNodeByServiceName(serviceName string) map[string]struct{} { return mapNodeId } -// GetNodeByTemplateServiceName 通过模板服务名获取服务名,返回 map[serviceName真实服务名]NodeId -func GetNodeByTemplateServiceName(templateServiceName string) map[string]string { +// GetNodeByTemplateServiceName 通过模板服务名获取服务名,返回 map[serviceName真实服务名][]NodeId +func GetNodeByTemplateServiceName(templateServiceName string) map[string][]string { cluster.locker.RLock() defer cluster.locker.RUnlock() mapServiceName := cluster.mapTemplateServiceNode[templateServiceName] - mapNodeId := make(map[string]string, 9) + mapNodeId := make(map[string][]string, 9) for serviceName := range mapServiceName { mapNode, ok := cluster.mapServiceNode[serviceName] if ok == false { @@ -425,7 +425,9 @@ func GetNodeByTemplateServiceName(templateServiceName string) map[string]string } for nodeId := range mapNode { - mapNodeId[serviceName] = nodeId + nodes := mapNodeId[serviceName] + nodes = append(nodes, nodeId) + mapNodeId[serviceName] = nodes } } diff --git a/network/processor/pbrawprocessor.go b/network/processor/pbrawprocessor.go index c75f8c0..c0bd814 100644 --- a/network/processor/pbrawprocessor.go +++ b/network/processor/pbrawprocessor.go @@ -10,7 +10,7 @@ type RawMessageInfo struct { msgHandler RawMessageHandler } -type RawMessageHandler func(clientId string, packType uint16, msg []byte) +type RawMessageHandler func(clientId string, packType uint16,additionData any, msg []byte) type RawConnectHandler func(clientId string) type UnknownRawMessageHandler func(clientId string, msg []byte) @@ -41,7 +41,7 @@ func (pbRawProcessor *PBRawProcessor) SetByteOrder(littleEndian bool) { // MsgRoute must goroutine safe func (pbRawProcessor *PBRawProcessor) MsgRoute(clientId string, msg interface{}, recyclerReaderBytes func(data []byte)) error { pPackInfo := msg.(*PBRawPackInfo) - pbRawProcessor.msgHandler(clientId, pPackInfo.typ, pPackInfo.rawMsg) + pbRawProcessor.msgHandler(clientId, pPackInfo.typ, nil, pPackInfo.rawMsg) recyclerReaderBytes(pPackInfo.rawMsg) return nil diff --git a/network/processor/processor.go b/network/processor/processor.go index 9b4e42d..f6a7cae 100644 --- a/network/processor/processor.go +++ b/network/processor/processor.go @@ -20,7 +20,6 @@ type IRawProcessor interface { SetByteOrder(littleEndian bool) SetRawMsgHandler(handle RawMessageHandler) - MakeRawMsg(msgType uint16, msg []byte, pbRawPackInfo *PBRawPackInfo) SetUnknownMsgHandler(unknownMessageHandler UnknownRawMessageHandler) SetConnectedHandler(connectHandler RawConnectHandler) SetDisConnectedHandler(disconnectHandler RawConnectHandler)