Files
hjha-server/GameModule/GlobalManager/GamePack.cs
xiaoou e9616125ce feat: initial commit - HJHA game server full source
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
2026-07-07 12:02:15 +08:00

113 lines
2.6 KiB
C#

/*
* 由SharpDevelop创建。
* 用户: Administrator
* 日期: 2018-11-16
* 时间: 10:52
*
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using System.Text;
using Server.Data;
using Server.Core;
using GameData;
namespace Server.Pack
{
/// <summary>
/// 游戏包
/// </summary>
public class GamePack : Reference
{
/// <summary>
/// 发包的玩家
/// </summary>
public PlayerDataAsyc pl;
/// <summary>
/// 包头
/// </summary>
public PackHead Head
{
get;
private set;
}
private string m_JsonData;
/// <summary>
/// 包数据
/// </summary>
public string JsonData
{
get
{
if (m_JsonData == null && IsBinary && Data != null)
{
m_JsonData = Encoding.UTF8.GetString(Data);
}
return m_JsonData;
}
}
public byte[] Data
{
get;
private set;
}
public bool IsText
{
get;
private set;
}
public bool IsBinary
{
get;
private set;
}
public static GamePack Create(PackHead head)
{
GamePack gamePack = ReferencePool.Fetch<GamePack>();
gamePack.Head = head;
gamePack.Data = null;
gamePack.IsBinary = true;
gamePack.IsText = false;
return gamePack;
}
public static GamePack Create(PackHead head,byte[] data)
{
GamePack gamePack = ReferencePool.Fetch<GamePack>();
gamePack.Head = head;
gamePack.Data = data;
gamePack.IsBinary = true;
gamePack.IsText = false;
return gamePack;
}
public static GamePack Create(PackHead head,string jsonData)
{
GamePack gamePack = ReferencePool.Fetch<GamePack>();
gamePack.Head = head;
gamePack.m_JsonData = jsonData;
gamePack.IsText = true;
gamePack.IsBinary = false;
return gamePack;
}
public override void Dispose()
{
this.pl = null;
this.m_JsonData = null;
this.Head = null;
this.Data = null;
ReferencePool.Recycle(this);
}
}
}