Files
hjha-server/ServerCore/NetWork/AChannel.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

96 lines
2.3 KiB
C#

using System;
using System.IO;
using System.Net;
namespace Server.Net
{
public enum ChannelType
{
Connect,
Accept,
}
public struct Packet
{
public const int MinPacketSize = MessageIndex + OpcodeLength;
public const int ActorIdLength = 3;
public const int OpcodeLength = 4;
public const int MessageIndex = ActorIdLength + ActorIdLength;
public ushort Opcode;
public MemoryStream MemoryStream;
}
public struct RouterPacket
{
/// <summary>
/// 总长度
/// </summary>
public const int TotalLength = 4;
/// <summary>
/// 路由包长度
/// </summary>
public const int RouterPacketLength = 4;
/// <summary>
/// 路由包长度索引
/// </summary>
public const int RouterPacketLengthIndex = TotalLength;
/// <summary>
/// 路由包类型
/// </summary>
public const int RouterPacketOpcode = 4;
public const int RouterPacketOpcodeIndex = TotalLength + RouterPacketLength;
public const int RouterPacketBodyIndex = TotalLength + RouterPacketLength + RouterPacketOpcode;
/// <summary>
/// 路由包数据的最小长度
/// </summary>
public const int RouterPacketMinLength = TotalLength + RouterPacketLength + RouterPacketOpcode;
/// <summary>
/// 客户端包长度
/// </summary>
public const int ClientPacketLength = 4;
/// <summary>
/// 客户端包类型
/// </summary>
public const int ClientPacketOpcode = 4;
}
public abstract class AChannel : IDisposable
{
public long Id;
public ChannelType ChannelType { get; protected set; }
private IPEndPoint remoteAddress;
public IPEndPoint RemoteAddress
{
get
{
return this.remoteAddress;
}
set
{
this.remoteAddress = value;
}
}
public bool IsDisposed
{
get
{
return this.Id == 0;
}
}
public abstract void Dispose();
}
}