mirror of
https://github.com/project-redbud/FunGame-Server.git
synced 2025-04-22 12:09:36 +08:00
使用ReceiveArray()读取 (#16)
This commit is contained in:
parent
cef4c80c9e
commit
de293557ab
@ -30,10 +30,6 @@
|
|||||||
<Content Include="logo.ico" />
|
<Content Include="logo.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\FunGame.Implement\FunGame.Implement.csproj" />
|
<ProjectReference Include="..\FunGame.Implement\FunGame.Implement.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -3,6 +3,7 @@ using Milimoe.FunGame.Core.Api.Utility;
|
|||||||
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.SQLScript.Common;
|
using Milimoe.FunGame.Core.Library.SQLScript.Common;
|
||||||
|
using Milimoe.FunGame.Core.Library.SQLScript.Entity;
|
||||||
using Milimoe.FunGame.Server.Model;
|
using Milimoe.FunGame.Server.Model;
|
||||||
using Milimoe.FunGame.Server.Others;
|
using Milimoe.FunGame.Server.Others;
|
||||||
using Milimoe.FunGame.Server.Utility;
|
using Milimoe.FunGame.Server.Utility;
|
||||||
@ -166,17 +167,21 @@ void StartServer()
|
|||||||
bool Read(ClientSocket socket)
|
bool Read(ClientSocket socket)
|
||||||
{
|
{
|
||||||
// 接收客户端消息
|
// 接收客户端消息
|
||||||
SocketObject read = socket.Receive();
|
foreach (SocketObject read in socket.ReceiveArray())
|
||||||
SocketMessageType type = read.SocketType;
|
|
||||||
object[] objs = read.Parameters;
|
|
||||||
if (type != SocketMessageType.Unknown)
|
|
||||||
{
|
{
|
||||||
if (objs[0] != null && objs[0].GetType() == typeof(string) && objs[0].ToString()!.Trim() != "")
|
SocketMessageType type = read.SocketType;
|
||||||
ServerHelper.WriteLine("[" + ServerSocket.GetTypeString(type) + "] " + ServerHelper.MakeClientName(socket.ClientIP) + " -> " + objs[0]);
|
if (type == SocketMessageType.Connect)
|
||||||
else
|
{
|
||||||
ServerHelper.WriteLine("[" + ServerSocket.GetTypeString(type) + "] " + ServerHelper.MakeClientName(socket.ClientIP));
|
if (read.Parameters.Length > 0)
|
||||||
|
{
|
||||||
|
string str = (read.GetParam<string>(0) ?? "").Trim();
|
||||||
|
if (str != "") ServerHelper.WriteLine("[" + ServerSocket.GetTypeString(type) + "] " + ServerHelper.MakeClientName(socket.ClientIP) + " -> " + str);
|
||||||
|
}
|
||||||
|
else ServerHelper.WriteLine("[" + ServerSocket.GetTypeString(type) + "] " + ServerHelper.MakeClientName(socket.ClientIP));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ServerHelper.WriteLine("客户端发送了不符合FunGame规定的字符,拒绝连接。");
|
ServerHelper.WriteLine("客户端发送了不符合FunGame规定的字符,拒绝连接。");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user