diff --git a/Server/PacketHandlers/LoginInfoHandler.cs b/Server/PacketHandlers/LoginInfoHandler.cs index 5e34941..d9fddad 100644 --- a/Server/PacketHandlers/LoginInfoHandler.cs +++ b/Server/PacketHandlers/LoginInfoHandler.cs @@ -1,9 +1,12 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; +using NetCoreServer; using Newtonsoft.Json; using Server.DB; using Server.DB.Documents; +using Server.Packets; using Server.Packets.Incoming; +using Server.Packets.Outgoing; namespace Server.PacketHandlers; @@ -39,8 +42,22 @@ public class LoginHandler : IPacketHandler } } - var accounts = _wonderkingContext.Accounts.ToArray(); - Parallel.ForEach(accounts.AsParallel(), - (x, i) => { _logger.LogInformation("Account {Data}", JsonConvert.SerializeObject(x)); }); + var loginResponsePacket = new LoginResponsePacket + { + LoginResponseReason = LoginResponseReason.OK, + ChannelData = new[] + { + new ServerChannelData + { + ChannelId = 0, + LoadPercentage = 200, + ServerId = 0 + } + }, + UnknownFlag = 1, + IsGameMaster = true + }; + var sess = session as AuthSession; + sess.Send(loginResponsePacket); } } \ No newline at end of file diff --git a/Server/Packets/Outgoing/LoginResponse.cs b/Server/Packets/Outgoing/LoginResponsePacket.cs similarity index 78% rename from Server/Packets/Outgoing/LoginResponse.cs rename to Server/Packets/Outgoing/LoginResponsePacket.cs index d05df53..204a5e4 100644 --- a/Server/Packets/Outgoing/LoginResponse.cs +++ b/Server/Packets/Outgoing/LoginResponsePacket.cs @@ -1,23 +1,22 @@ namespace Server.Packets.Outgoing; [PacketId(OperationCode.LoginResponse)] -public class LoginResponse : IPacket +public class LoginResponsePacket : IPacket { public LoginResponseReason LoginResponseReason; public byte UnknownFlag = 1; public bool IsGameMaster; - public ushort ChannelAmount; - private ServerChannelData[] ChannelData; + public ServerChannelData[] ChannelData; public void Deserialize(byte[] data) { LoginResponseReason = (LoginResponseReason)data[0]; UnknownFlag = data[1]; IsGameMaster = BitConverter.ToBoolean(data, 2); - ChannelAmount = BitConverter.ToUInt16(data, 3); + var channelAmount = BitConverter.ToUInt16(data, 3); var sizeOfServerChannelData = 5; - ChannelData = Enumerable.Repeat(0, ChannelAmount).Select(i => new ServerChannelData + ChannelData = Enumerable.Repeat(0, channelAmount).Select(i => new ServerChannelData { ServerId = BitConverter.ToUInt16(data, 5 + 0 + i * sizeOfServerChannelData), ChannelId = BitConverter.ToUInt16(data, 5 + 2 + i * sizeOfServerChannelData), @@ -28,16 +27,16 @@ public class LoginResponse : IPacket public byte[] Serialize() { var sizeOfServerChannelData = 5; - Span dataSpan = stackalloc byte[5 + ChannelAmount * sizeOfServerChannelData]; - dataSpan.Fill(0); + Span dataSpan = stackalloc byte[5 + ChannelData.Length * sizeOfServerChannelData]; + dataSpan.Clear(); dataSpan[0] = (byte)LoginResponseReason; dataSpan[1] = UnknownFlag; dataSpan[2] = BitConverter.GetBytes(IsGameMaster)[0]; - var bytesOfChannelAmount = BitConverter.GetBytes(ChannelAmount); + var bytesOfChannelAmount = BitConverter.GetBytes((ushort)ChannelData.Length); dataSpan[3] = bytesOfChannelAmount[0]; dataSpan[4] = bytesOfChannelAmount[1]; - for (var i = 0; i < ChannelAmount; i++) + for (var i = 0; i < ChannelData.Length; i++) { var bytesOfServerId = BitConverter.GetBytes(ChannelData[i].ServerId); var bytesOfChannelId = BitConverter.GetBytes(ChannelData[i].ChannelId);