Ejemplo n.º 1
0
        private static unsafe void OnClientReceive(WinsockClient Socket, byte[] Packet, int Length)
        {
            GameClient Client = Socket.Wrapper as GameClient;
            Client.Decrypt(Packet);

            PacketProcessor.Process(Client, Packet);
        }
Ejemplo n.º 2
0
        public void Disconnect(WinsockClient Client)
        {
            if (OnClientDisconnected != null)
                OnClientDisconnected(Client, null);

            Client.Dispose();
        }
Ejemplo n.º 3
0
        private static void OnClientDisconnect(WinsockClient Socket, object NullParam)
        {
            GameClient Client = Socket.Wrapper as GameClient;
            Database.SaveCharacter(Client);

            Client.RemoveFromScreen();

            EntityManager.Remove(Client);
        }
Ejemplo n.º 4
0
        public void Disconnect(WinsockClient Client)
        {
            if (OnClientDisconnected != null)
            {
                OnClientDisconnected(Client, null);
            }

            Client.Dispose();
        }
Ejemplo n.º 5
0
        private void AcceptConnectionCallback(IAsyncResult result)
        {
            try
            {
                WinsockClient Client = new WinsockClient(this, Connection.EndAccept(result), BufferSize, CreatePacketCipher());
                if (OnClientConnected != null)
                {
                    OnClientConnected.Invoke(Client, null);
                }
                Client.BeginReceive();
                Connection.BeginAccept(new AsyncCallback(AcceptConnectionCallback), null);
            }
            catch (Exception exception)
            {
#if DEBUG
                Console.WriteLine(exception.ToString());
#endif
            }
        }
Ejemplo n.º 6
0
 private void AcceptConnectionCallback(IAsyncResult result)
 {
     try
     {
         WinsockClient Client = new WinsockClient(this, Connection.EndAccept(result), BufferSize, CreatePacketCipher());
         if (OnClientConnected != null)
         {
             OnClientConnected.Invoke(Client, null);
         }
         Client.BeginReceive();
         Connection.BeginAccept(new AsyncCallback(AcceptConnectionCallback), null);
     }
     catch (Exception exception)
     {
     #if DEBUG
         Console.WriteLine(exception.ToString());
     #endif
     }
 }
Ejemplo n.º 7
0
        public GameClient(WinsockClient Socket)
        {
            this.Socket = Socket;

            SendLock = new object();

            Cryptography = new GameCryptography();
            Cryptography.Initialize();

            Entity = new Entity(this);
            Screen = new Screen(this);
            PacketQueue = new PacketQueue();

            Inventory = new List<ConquerItem>();
            Profiencys = new List<LearnProfiency>();
            Spells = new List<LearnSpell>();

            Equipment = new Dictionary<ItemPosition, ConquerItem>();

            Status = LoginStatus.Logging;
        }
Ejemplo n.º 8
0
        private static unsafe void OnClientReceive(WinsockClient Socket, byte[] Packet, int Length)
        {
            AuthClient Client = Socket.Wrapper as AuthClient;
            Client.Decrypt(Packet);

            fixed (byte* pPacket = Packet)
            {
                ushort Size = *(ushort*)pPacket;
                ushort Type = *(ushort*)(pPacket + 2);
                HexDump(Packet, "Client -> Server", Size, Type);

                switch (Type)
                {
                    case 0x41B:
                        {
                            AuthRequest* Request = (AuthRequest*)pPacket;
                            string Username = new string(Request->Username, 0, 16).Trim('\x00');
                            string Password = PasswordCipher.Decrypt((uint*)Request->Password);
                            string Server = new string(Request->Server, 0, 16).Trim('\x00');

                            string Address = "";
                            if (Database.ServerExists(Server, out Address))
                            {
                                if (Database.AccountExists(Username, Password, Client))
                                {
            #if LOCAL_VERSION
                                    IPHostEntry entry = Dns.GetHostEntry(Dns.GetHostName());
                                    foreach (IPAddress address in entry.AddressList)
                                    {
                                        if (address.AddressFamily == AddressFamily.InterNetwork)
                                        {
                                            string local_ip = address.ToString();
                                            if (local_ip.StartsWith("10"))
                                            {
                                                Address = local_ip;
                                                break;
                                            }
                                        }

                                    }
            #endif
                                    SendAuthResponse(Client, Address, 5816);
                                }
                                else
                                {
                                    SendAuthReject(Client, InvalidCredentials());
                                    //Client.Disconnect();
                                }
                            }

                        } break;
                }
            }
        }
Ejemplo n.º 9
0
 private static void OnClientDisconnect(WinsockClient Socket, object NullParam)
 {
 }
Ejemplo n.º 10
0
 private static void OnClientConnect(WinsockClient Socket, object NullParam)
 {
     Socket.Wrapper = new AuthClient(Socket);
 }
Ejemplo n.º 11
0
 public AuthClient(WinsockClient Socket)
 {
     this.Socket = Socket;
     Cipher = new AuthCryptography();
     Cipher.Initialize();
 }