拆分战斗服务器

This commit is contained in:
huangxiaolei
2022-12-19 22:11:55 +08:00
parent cf4804c444
commit 0dc45708d6
21 changed files with 793 additions and 349 deletions

31
common/mq/topic.go Normal file
View File

@@ -0,0 +1,31 @@
package mq
import (
"strings"
)
const (
GATE = "GATE_${APPID}_HK4E"
GS = "GS_${APPID}_HK4E"
FIGHT = "FIGHT_${APPID}_HK4E"
)
func (m *MessageQueue) getTopic(serverType string, appId string) string {
topic := strings.ReplaceAll(serverType, "${APPID}", appId)
return topic
}
func (m *MessageQueue) SendToGate(appId string, netMsg *NetMsg) {
netMsg.Topic = m.getTopic(GATE, appId)
m.netMsgInput <- netMsg
}
func (m *MessageQueue) SendToGs(appId string, netMsg *NetMsg) {
netMsg.Topic = m.getTopic(GS, appId)
m.netMsgInput <- netMsg
}
func (m *MessageQueue) SendToFight(appId string, netMsg *NetMsg) {
netMsg.Topic = m.getTopic(FIGHT, appId)
m.netMsgInput <- netMsg
}