mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-04-21 11:39:35 +08:00
parent
e1c3f7cce1
commit
ecdb321eb6
@ -42,7 +42,7 @@ namespace Milimoe.FunGame.Core.Api.Transmittal
|
||||
return default;
|
||||
}
|
||||
|
||||
private class Request : BaseModel
|
||||
private class Request : BaseController
|
||||
{
|
||||
public Hashtable RequestData { get; } = new();
|
||||
public Hashtable ResultData { get; } = new();
|
||||
|
@ -28,8 +28,4 @@
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Library\Server\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,10 +0,0 @@
|
||||
namespace Milimoe.FunGame.Core.Library.Common.Architecture
|
||||
{
|
||||
public abstract class BaseController
|
||||
{
|
||||
/// <summary>
|
||||
/// 重写此方法并调用Model的Dispose方法,否则将无法正常将监听Socket的事件移除!
|
||||
/// </summary>
|
||||
public abstract void Dispose();
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ using Milimoe.FunGame.Core.Service;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Library.Common.Architecture
|
||||
{
|
||||
public class BaseModel : ISocketHandler, IDisposable
|
||||
public class BaseController : ISocketHandler, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// 接收到的SocketObject实例
|
||||
@ -25,7 +25,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Architecture
|
||||
/// 继承请调用base构造
|
||||
/// </summary>
|
||||
/// <param name="socket">Socket</param>
|
||||
public BaseModel(Socket? socket)
|
||||
public BaseController(Socket? socket)
|
||||
{
|
||||
if (socket != null)
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ using Milimoe.FunGame.Core.Library.Constant;
|
||||
namespace Milimoe.FunGame.Core.Library.Common.Network
|
||||
{
|
||||
[Serializable]
|
||||
public class JsonObject
|
||||
public struct JsonObject
|
||||
{
|
||||
public SocketMessageType MessageType { get; } = SocketMessageType.Unknown;
|
||||
public Guid Token { get; }
|
||||
@ -34,7 +34,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Network
|
||||
return new JsonObject(MessageType, Token, Parameters).JsonString;
|
||||
}
|
||||
|
||||
public static JsonObject? GetObject(string JsonString)
|
||||
public static JsonObject GetObject(string JsonString)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<JsonObject>(JsonString);
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Numerics;
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Library.Common.Architecture
|
||||
namespace Milimoe.FunGame.Core.Model
|
||||
{
|
||||
public class RoomList : IEnumerable
|
||||
public class RoomListModel : IEnumerable
|
||||
{
|
||||
private readonly Hashtable _List = new();
|
||||
private readonly Hashtable _PlayerList = new();
|
||||
@ -16,7 +15,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Architecture
|
||||
|
||||
public List<string> ListRoomID => _List.Keys.Cast<string>().ToList();
|
||||
|
||||
public RoomList()
|
||||
public RoomListModel()
|
||||
{
|
||||
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
namespace Milimoe.FunGame.Core.Others
|
||||
{
|
||||
internal class Others
|
||||
{
|
||||
}
|
||||
}
|
@ -40,6 +40,7 @@ namespace Milimoe.FunGame.Core.Service
|
||||
IPEndPoint ServerEndPoint = new(IPAddress.Any, Port);
|
||||
_ServerSocket.Bind(ServerEndPoint);
|
||||
_ServerSocket.Listen(MaxConnection);
|
||||
_ServerSocket.NoDelay = true;
|
||||
return _ServerSocket;
|
||||
}
|
||||
catch
|
||||
@ -61,6 +62,7 @@ namespace Milimoe.FunGame.Core.Service
|
||||
try
|
||||
{
|
||||
Client = ServerSocket.Accept();
|
||||
Client.NoDelay = true;
|
||||
IPEndPoint? ClientIPEndPoint = (IPEndPoint?)Client.RemoteEndPoint;
|
||||
ClientIP = (ClientIPEndPoint != null) ? ClientIPEndPoint.ToString() : "Unknown";
|
||||
return new object[] { ClientIP, Client };
|
||||
@ -95,6 +97,7 @@ namespace Milimoe.FunGame.Core.Service
|
||||
ClientSocket.Connect(ServerEndPoint);
|
||||
if (ClientSocket.Connected)
|
||||
{
|
||||
ClientSocket.NoDelay = true;
|
||||
_Socket = ClientSocket;
|
||||
return _Socket;
|
||||
}
|
||||
@ -167,11 +170,8 @@ namespace Milimoe.FunGame.Core.Service
|
||||
if (length > 0)
|
||||
{
|
||||
string msg = General.DefaultEncoding.GetString(buffer, 0, length);
|
||||
Library.Common.Network.JsonObject? json = Library.Common.Network.JsonObject.GetObject(msg);
|
||||
if (json != null)
|
||||
{
|
||||
Library.Common.Network.JsonObject json = Library.Common.Network.JsonObject.GetObject(msg);
|
||||
result = new Library.Common.Network.SocketObject(json);
|
||||
}
|
||||
// 客户端接收消息,广播ScoketObject到每个UIModel
|
||||
OnSocketReceive(result);
|
||||
return result;
|
||||
@ -196,11 +196,8 @@ namespace Milimoe.FunGame.Core.Service
|
||||
if (length > 0)
|
||||
{
|
||||
string msg = General.DefaultEncoding.GetString(buffer, 0, length);
|
||||
Library.Common.Network.JsonObject? json = Library.Common.Network.JsonObject.GetObject(msg);
|
||||
if (json != null)
|
||||
{
|
||||
Library.Common.Network.JsonObject json = Library.Common.Network.JsonObject.GetObject(msg);
|
||||
result = new Library.Common.Network.SocketObject(json);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user