public override Packet OnPacketReceive(Packet receivedPacket)
        {
            ClientPacketDownloadPetsID clientPacketDownloadPetsID = receivedPacket as ClientPacketDownloadPetsID;

            ConsoleHelper.Write("Receive - ClientPacketDownloadPetsID");

            int userID = clientPacketDownloadPetsID.UserID;

            List <int> ownPetIdList   = SQLHelper.GetIDList($"SELECT `fkPetID` FROM `T_Own` WHERE `fkUserID`='{userID}'", 0);
            List <int> sharePetIdList = SQLHelper.GetIDList($"SELECT `fkPetID` FROM `T_Share` WHERE `fkReceiverID`='{userID}'", 0);

            int[] petID       = new int[ownPetIdList.Count];
            int[] sharedPetID = new int[sharePetIdList.Count];

            for (int i = 0; i < ownPetIdList.Count; i++)
            {
                petID[i] = ownPetIdList[i];
            }

            for (int i = 0; i < sharePetIdList.Count; i++)
            {
                sharedPetID[i] = sharePetIdList[i];
            }

            ConsoleHelper.Write("Send - ServerPacketDownloadPetsID");

            return(new ServerPacketDownloadPetsID(petID, sharedPetID));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Downloads the pets identifier.
        /// </summary>
        /// <returns>The pets identifier.</returns>
        /// <param name="user">User.</param>
        public static ServerPacketDownloadPetsID DownloadPetsID(PLFUser user)
        {
            //get user id
            int userID = user.ID;

            //create new client packet download pets id
            ClientPacketDownloadPetsID clientPacketDownloadPetsID = new ClientPacketDownloadPetsID(userID);

            //send packet to the server
            ServerPacketDownloadPetsID serverPacketDownloadPetsID = TCPClient.SendPacket(clientPacketDownloadPetsID) as ServerPacketDownloadPetsID;

            //if null answer, return vanilla packet
            if (serverPacketDownloadPetsID == null)
            {
                return(new ServerPacketDownloadPetsID(new int[0], new int[0]));
            }

            //return packet
            return(serverPacketDownloadPetsID);
        }