Files
hjha-server/GameNetModule/GameNet/Base/BaseWChannel.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

49 lines
1.3 KiB
C#

using System.Threading.Tasks;
using MrWu.Debug;
using WebSocketSharp;
using WebSocketSharp.Server;
namespace Server.Net
{
public abstract class BaseWChannel : WebSocketBehavior
{
public bool Active
{
get { return ReadyState == WebSocketState.Open; }
}
public string RemoteEndPointIP {
get
{
string ipAddress = null;
if (this.Headers["X-Forwarded-For"] != null)
{
ipAddress = this.Headers["X-Forwarded-For"];
}else if (this.Headers["X-Real-IP"] != null)
{
ipAddress = this.Headers["X-Real-IP"];
}
if (ipAddress == null)
{
return this.UserEndPoint.Address.ToString();
}
if (ipAddress.IndexOf(',') >= 0)
{
string[] ss = ipAddress.Split(',');
ipAddress = ss[0];
}
return ipAddress.Trim();
}
}
public void BeginDisconnect()
{
Task.Factory.StartNew(Close);
}
}
}