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
This commit is contained in:
49
GameNetModule/GameNet/Base/BaseWChannel.cs
Normal file
49
GameNetModule/GameNet/Base/BaseWChannel.cs
Normal file
@ -0,0 +1,49 @@
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user