6 major server modules (PdkFriendServer/GlobalSever/ServerCore/GameModule/GameNetModule) + game logic (GameFix/GameDAL/ServerData) + network layer (NetWorkMessage) + data layer (ObjectModel) + utilities (MrWu/Core/Config/CloudAPI/dll) + adapters (zyxAdapter/base) .NET 8.0 C# solution, 16 projects, 958 source files
59 lines
1.5 KiB
C#
59 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Concurrent;
|
|
using MrWu.RabbitMQ;
|
|
using Server.Pack;
|
|
using GameData;
|
|
|
|
namespace Server.MQ {
|
|
/// <summary>
|
|
/// 消息池
|
|
/// </summary>
|
|
public class WaitBeMsgPool {
|
|
static WaitBeMsgPool() {
|
|
instace = new WaitBeMsgPool();
|
|
}
|
|
|
|
private WaitBeMsgPool() {
|
|
}
|
|
|
|
private static WaitBeMsgPool instace;
|
|
|
|
/// <summary>
|
|
/// 所有的消息
|
|
/// </summary>
|
|
private ConcurrentQueue<WaitBeMsg> msgs = new ConcurrentQueue<WaitBeMsg>();
|
|
|
|
/// <summary>
|
|
/// 获取消息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static WaitBeMsg GetWaiteBeMsg(Message msg) {
|
|
WaitBeMsg tmp = null;
|
|
if (!instace.msgs.TryDequeue(out tmp)) {
|
|
tmp = new WaitBeMsg();
|
|
}
|
|
|
|
tmp.message = msg;
|
|
tmp.AutoAck = true;
|
|
//ServerHead head = null;
|
|
tmp.jsondata = JsonPack.GetPackHead(msg.bodystr, out tmp.head);
|
|
//tmp.head = head;
|
|
return tmp;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 处理消息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static void PutWaiteBeMsg(ref WaitBeMsg msg) {
|
|
if (msg == null)
|
|
return;
|
|
msg.Clear();
|
|
instace.msgs.Enqueue(msg);
|
|
msg = null;
|
|
}
|
|
|
|
|
|
}
|
|
}
|