添加BaseServerModel,修改ThreadManager

This commit is contained in:
Mili 2023-02-25 21:19:04 +08:00
parent eaa1b7d228
commit 163ad53e48
4 changed files with 15 additions and 20 deletions

View File

@ -1,6 +0,0 @@
namespace FunGame.Server.Controller
{
internal class ServerController
{
}
}

View File

@ -2,20 +2,21 @@
using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Entity;
using Milimoe.FunGame.Core.Library.Common.Network; using Milimoe.FunGame.Core.Library.Common.Network;
using Milimoe.FunGame.Core.Library.Constant; using Milimoe.FunGame.Core.Library.Constant;
using Milimoe.FunGame.Core.Library.Server;
using Milimoe.FunGame.Server.Others; using Milimoe.FunGame.Server.Others;
using Milimoe.FunGame.Server.Utility; using Milimoe.FunGame.Server.Utility;
namespace Milimoe.FunGame.Server.Model namespace Milimoe.FunGame.Server.Model
{ {
public class ServerModel public class ServerModel : BaseModel
{ {
/** /**
* Public * Public
*/ */
public bool Running = false; public new bool Running = false;
public ClientSocket? Socket = null; public new ClientSocket? Socket = null;
public Task? Task = null; public new Task? Task = null;
public string ClientName = ""; public new string ClientName = "";
/** /**
* Private * Private
@ -32,7 +33,7 @@ namespace Milimoe.FunGame.Server.Model
Running = running; Running = running;
} }
public bool Read(ClientSocket socket) public override bool Read(ClientSocket socket)
{ {
// 接收客户端消息 // 接收客户端消息
try try
@ -140,7 +141,7 @@ namespace Milimoe.FunGame.Server.Model
} }
} }
public bool Send(ClientSocket socket, SocketMessageType type, params object[] objs) public override bool Send(ClientSocket socket, SocketMessageType type, params object[] objs)
{ {
// 发送消息给客户端 // 发送消息给客户端
try try
@ -165,7 +166,7 @@ namespace Milimoe.FunGame.Server.Model
} }
} }
public void Start() public override void Start()
{ {
Task StreamReader = Task.Factory.StartNew(() => Task StreamReader = Task.Factory.StartNew(() =>
{ {

View File

@ -1,8 +1,8 @@
using Milimoe.FunGame.Core.Library.Constant; using System.Collections;
using Milimoe.FunGame.Server.Model;
using System.Collections;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Text; using System.Text;
using Milimoe.FunGame.Core.Library.Constant;
using Milimoe.FunGame.Server.Model;
namespace Milimoe.FunGame.Server.Others namespace Milimoe.FunGame.Server.Others
{ {

View File

@ -1,8 +1,8 @@
using Milimoe.FunGame.Core.Api.Utility; using System.Collections;
using MySql.Data.MySqlClient;
using Milimoe.FunGame.Core.Api.Utility;
using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Entity;
using Milimoe.FunGame.Server.Others; using Milimoe.FunGame.Server.Others;
using MySql.Data.MySqlClient;
using System.Collections;
namespace Milimoe.FunGame.Server.Utility namespace Milimoe.FunGame.Server.Utility
{ {