Ai世界玩家人数超过4人测试

This commit is contained in:
flswld
2023-01-10 19:21:56 +08:00
parent 3ecdb6ff70
commit 1793054ef4
22 changed files with 596 additions and 251 deletions

View File

@@ -66,10 +66,10 @@ func Run(ctx context.Context, configFile string) error {
logger.Warn("gate start, appid: %v", APPID)
messageQueue := mq.NewMessageQueue(api.GATE, APPID, client)
defer messageQueue.Close()
connectManager := net.NewKcpConnectManager(messageQueue, client.Discovery)
connectManager.Start()
defer connectManager.Stop()
defer connectManager.Close()
go func() {
outputChan := connectManager.GetKcpEventOutputChan()

View File

@@ -64,10 +64,11 @@ func NewKcpConnectManager(messageQueue *mq.MessageQueue, discovery *rpc.Discover
r.localMsgOutput = make(chan *ProtoMsg, 1000)
r.createSessionChan = make(chan *Session, 1000)
r.destroySessionChan = make(chan *Session, 1000)
r.run()
return r
}
func (k *KcpConnectManager) Start() {
func (k *KcpConnectManager) run() {
// 读取密钥相关文件
k.signRsaKey, k.encRsaKeyMap, _ = region.LoadRsaKey()
// key
@@ -97,7 +98,7 @@ func (k *KcpConnectManager) Start() {
go k.acceptHandle(listener)
}
func (k *KcpConnectManager) Stop() {
func (k *KcpConnectManager) Close() {
k.closeAllKcpConn()
time.Sleep(time.Second * 3)
}