mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-12-05 00:06:02 +00:00
ScoketManager
This commit is contained in:
parent
256369ebb0
commit
d8489d654a
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Milimoe.FunGame.Core.Entity.Enum;
|
||||
using Milimoe.FunGame.Core.Others;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Api.Utility
|
||||
{
|
||||
|
||||
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Api.Utility
|
||||
{
|
||||
@ -41,7 +42,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
/// <returns></returns>
|
||||
public static object New<T>(params object[]? objs)
|
||||
{
|
||||
object instance = Core.Others.Constant.EntityInstance;
|
||||
object instance = General.EntityInstance;
|
||||
if (!IsEntity<T>()) return instance;
|
||||
if (objs is null || objs.Length == 0) return instance;
|
||||
if (typeof(T) == typeof(Entity.General.User))
|
||||
@ -66,7 +67,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
/// <returns></returns>
|
||||
public static object NewSingle<T>(params object[]? objs)
|
||||
{
|
||||
object instance = Core.Others.Constant.EntityInstance;
|
||||
object instance = General.EntityInstance;
|
||||
if (!IsEntity<T>()) return instance;
|
||||
if (objs is null || objs.Length == 0) return instance;
|
||||
if (typeof(T) == typeof(Entity.General.User))
|
||||
|
||||
@ -22,4 +22,8 @@
|
||||
<DebugType>embedded</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Library\Common\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
namespace Milimoe.FunGame.Core.Interface
|
||||
{
|
||||
/**
|
||||
* 接口需要在FunGame.Core项目中Implement文件夹创建新的类实现
|
||||
* 接口需要在FunGame.Core项目中创建新的类实现
|
||||
* namespace必须是Milimoe.FunGame.Core.Implement,文件夹位置随意
|
||||
* 参考:
|
||||
* using Milimoe.FunGame.Core.Interface;
|
||||
|
||||
|
||||
13
FunGame.Core/Library/Constant/General.cs
Normal file
13
FunGame.Core/Library/Constant/General.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Library.Constant
|
||||
{
|
||||
public class General
|
||||
{
|
||||
public static Entity.General.Empty EntityInstance { get; } = new();
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Others
|
||||
namespace Milimoe.FunGame.Core.Library.Constant
|
||||
{
|
||||
public enum InterfaceType
|
||||
{
|
||||
@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Entity.Exception
|
||||
namespace Milimoe.FunGame.Core.Library.Exception
|
||||
{
|
||||
public class SystemError : System.Exception
|
||||
{
|
||||
@ -6,8 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Others
|
||||
{
|
||||
public class Constant
|
||||
internal class Others
|
||||
{
|
||||
public static Entity.General.Empty EntityInstance = new Entity.General.Empty();
|
||||
}
|
||||
}
|
||||
@ -12,6 +12,15 @@ namespace Milimoe.FunGame.Core.Service
|
||||
{
|
||||
internal class SocketManager
|
||||
{
|
||||
internal static SocketManager? Instance { get; private set; }
|
||||
|
||||
internal Socket? Socket { get; } = null;
|
||||
|
||||
private SocketManager(Socket socket)
|
||||
{
|
||||
Socket = socket;
|
||||
}
|
||||
|
||||
internal static Socket? Connect(string IP, int Port = 22222)
|
||||
{
|
||||
Socket? socket = null;
|
||||
@ -29,6 +38,7 @@ namespace Milimoe.FunGame.Core.Service
|
||||
socket.Connect(ServerEndPoint);
|
||||
if (socket.Connected)
|
||||
{
|
||||
Instance = new SocketManager(socket);
|
||||
return socket;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,10 +7,10 @@ using System.Text;
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Entity.General;
|
||||
using Milimoe.FunGame.Core.Entity.Enum;
|
||||
using Milimoe.FunGame.Core.Others;
|
||||
using Milimoe.FunGame.Desktop.Entity.Component;
|
||||
using Milimoe.FunGame.Desktop.Others;
|
||||
using Milimoe.FunGame.Desktop.Utils;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Desktop.UI
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user