public static void ParsePacket(ClientManager MyClient, byte[] data) { if (MyClient == null) { return; } if (MyClient._socket == null) { return; } if (!MyClient._socket.Connected) { return; } byte[] PacketDecrypted = PacketFunctions.GetPacketDataDecrypted(data); using (MemoryStream ms = new MemoryStream(PacketDecrypted)) { using (BinaryReader br = new BinaryReader(ms)) { int id_idx = br.ReadInt32(); if (!ClientFunctions.SearchUserIDInSession(id_idx)) { Console.WriteLine("Client not found in list"); return; } br.ReadByte(); byte PacketType = br.ReadByte(); if (MyClient.data.Authenticated) { switch (PacketType) { case 2: // load characters data //Console.WriteLine("Receive load character!"); SendData.SendResponseLoadCharacters(MyClient); SendData.SendResponseGMSInfo(MyClient); return; break; case 3: // send create character prev data //Console.WriteLine("Receive get create char data!"); SendData.SendResponseCreateCharData(MyClient); return; break; case 4: // delete character //Console.WriteLine("Receive delete hero request!"); ProcessDeleteHeroReceive(MyClient, PacketDecrypted); return; break; case 5: // create hero //Console.WriteLine("Receive create hero!"); ProcessCreateHeroReceive(MyClient, PacketDecrypted); return; break; case 6: // select hero Console.WriteLine("[HeroSelect] Request hero select."); ProcessHeroSelected(MyClient, PacketDecrypted); break; case 10: // guild mark list break; case 32: // change heroname break; } } float exe_version = br.ReadSingle(); if (exe_version != MyInfo.EXE_VERSION) { //Console.WriteLine("Client use exe_version old version"); // disconnect by using client old_version return; } int id_idx2 = br.ReadInt32(); int LGS_TOKEN = br.ReadInt32(); byte[] username_bytes = br.ReadBytes(32); string username = PacketFunctions.ExtractStringFromBytes(username_bytes); if (!ClientFunctions.TokenIsValidInSession(id_idx2, LGS_TOKEN, username)) { //Console.WriteLine("Incorrect token!"); // disconnect by using a incorrect token return; } MyClient.data.id_idx = id_idx2; // copy id_idx valid from packet MyClient.data.username = username; // copy username valid from packet MyClient.data.Authenticated = true; // confirm client authenticated aprove SendData.SendAprovedAuthentication(MyClient); SendData.SendAprovedSession(MyClient); //Console.WriteLine("[W] User auth aproved! " + username + ":" + id_idx2); } } }