diff --git a/Source/Client/AuthClient.cs b/Source/Client/AuthClient.cs new file mode 100644 index 0000000..d97ec9c --- /dev/null +++ b/Source/Client/AuthClient.cs @@ -0,0 +1,35 @@ +using System; +using Conquer_Online_Server.Network.Cryptography; +using System.Net.Sockets; +using Conquer_Online_Server.Network.Sockets; +using Conquer_Online_Server.Network; + +namespace Conquer_Online_Server.Client +{ + public class AuthClient + { + private ClientWrapper _socket; + public Network.AuthPackets.Authentication Info; + public Database.AccountTable Account; + public Network.Cryptography.AuthCryptography Cryptographer; + public int PasswordSeed; + public ConcurrentPacketQueue Queue; + public AuthClient(ClientWrapper socket) + { + Queue = new ConcurrentPacketQueue(0); + _socket = socket; + } + public void Send(byte[] buffer) + { + byte[] _buffer = new byte[buffer.Length]; + Buffer.BlockCopy(buffer, 0, _buffer, 0, buffer.Length); + Cryptographer.Encrypt(_buffer); + _socket.Send(_buffer); + } + public void Send(Interfaces.IPacket buffer) + { + Send(buffer.ToArray()); + } + public static uint nextID = 0; + } +} diff --git a/Source/Client/AuthState.cs b/Source/Client/AuthState.cs deleted file mode 100644 index 3f195bf..0000000 --- a/Source/Client/AuthState.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using Conquer_Online_Server.Network.Cryptography; -using System.Net.Sockets; -using System.Collections.Generic; -using Conquer_Online_Server.Network.Sockets; - -namespace Conquer_Online_Server.Client -{ - public class AuthState - { - private bool Alive = false; - public Network.AuthPackets.Authentication Info; - - public Database.AccountTable Account; - public Network.Cryptography.AuthCryptography Cryptographer; - public int PasswordSeed; - public WinSocket _socket; - - public AuthState(WinSocket socket) - { - _socket = socket; - Alive = true; - } - public void Send(byte[] buffer) - { - if (Alive) - { - byte[] _buffer = new byte[buffer.Length]; - Buffer.BlockCopy(buffer, 0, _buffer, 0, buffer.Length); - lock (Cryptographer) - { - Cryptographer.Encrypt(_buffer); - try - { - _socket.Send(_buffer); - } - catch (Exception e)//posible proxy/food with proxy - { - Console.WriteLine(e.ToString()); - Program.SaveException(e); - this.Disconnect(); - } - } - } - } - public void Send(Interfaces.IPacket buffer) - { - Send(buffer.ToArray()); - } - - public void Disconnect() - { - if (Alive) - { - - Alive = false; - _socket.Disconnect(false); - } - } - public static uint nextID = 0; - - } -}