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
113 lines
3.4 KiB
C#
113 lines
3.4 KiB
C#
/*
|
|
* 由SharpDevelop创建。
|
|
* 用户: Administrator
|
|
* 日期: 2018-10-30
|
|
* 时间: 16:00
|
|
*
|
|
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
|
|
*/
|
|
|
|
using System;
|
|
using GameData;
|
|
using MrWu.Debug;
|
|
using MrWu.RabbitMQ;
|
|
using Server.Pack;
|
|
|
|
namespace Server.MQ {
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class GameFilter : IMQFilter {
|
|
string IMQFilter.Name {
|
|
get {
|
|
return "GameFilter";
|
|
}
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public Action<PackHead, string> SocketMessageHandler {
|
|
get;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public readonly ServerNode myUtil;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="socketMessageHandler"></param>
|
|
/// <param name="myUtil"></param>
|
|
public GameFilter(Action<PackHead, string> socketMessageHandler, ServerNode myUtil) {
|
|
SocketMessageHandler = socketMessageHandler;
|
|
this.myUtil = myUtil;
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="message"></param>
|
|
/// <param name="msgDesc"></param>
|
|
/// <returns></returns>
|
|
public bool Filter(Message message, Recv2ReturnDescription msgDesc) {
|
|
var jsondata = JsonPack.GetPackHead(message.bodystr, out PackHead head);
|
|
if (head == null)
|
|
return false;
|
|
if (myUtil.Equals(head.gameNode)) { //是本游戏 直接发送
|
|
return true;
|
|
} else { //不是本游戏 转发给别的Socket
|
|
Debug.Error("这个包没带游戏标志:" + head.packlx);
|
|
return false;
|
|
}
|
|
//return head?.packlx == GamePackAgreement.TransFerPack;
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="message"></param>
|
|
/// <param name="msgDesc"></param>
|
|
/// <returns></returns>
|
|
public object HandleMessage(Message message, Recv2ReturnDescription msgDesc) {
|
|
var jsondata = JsonPack.GetPackHead(message.bodystr, out PackHead head);
|
|
head.packlx = head.transfer;
|
|
SocketMessageHandler(head, jsondata);
|
|
return null;
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="msg"></param>
|
|
/// <param name="msgDesc"></param>
|
|
/// <returns></returns>
|
|
public bool CallFilter(string msg, Recv2ReturnDescription msgDesc) {
|
|
return false;
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="msg"></param>
|
|
/// <param name="msgDesc"></param>
|
|
/// <returns></returns>
|
|
public object HandleCallMessage(string msg, Recv2ReturnDescription msgDesc) {
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public bool FilterCallback(Message message) {
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="message"></param>
|
|
public void HandleCallbackMessage(Message message) {
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|