コード例 #1
0
        public override Packet OnPacketReceive(Packet receivedPacket)
        {
            ClientPacketKillSharePet clientPacketKillSharePet = receivedPacket as ClientPacketKillSharePet;

            ConsoleHelper.Write("Receive - ClientPacketKillSharePet");

            int userID = clientPacketKillSharePet.ReceiverUserID;
            int petID  = clientPacketKillSharePet.PetID;

            //insert new profile into DB
            MySqlCommand killPetShareCommand = new MySqlCommand();

            killPetShareCommand.Connection  = Program.mySQLManager.MySQLConnection.MysqlConnection;
            killPetShareCommand.CommandText =
                $"DELETE FROM `T_Share` WHERE `fkPetID`='{petID}' AND `fkReceiverID`='{userID}'";

            ServerPacketConfirmation serverPacketConfirmation;

            try
            {
                killPetShareCommand.ExecuteNonQuery();
                serverPacketConfirmation = new ServerPacketConfirmation(true, NetworkError.NONE);
            }
            catch
            {
                serverPacketConfirmation = new ServerPacketConfirmation(false, NetworkError.GLOBAL_UNKNOWN);
            }

            ConsoleHelper.Write("Send - ServerPacketConfirmation");

            return(serverPacketConfirmation);
        }
コード例 #2
0
ファイル: ServerHelper.cs プロジェクト: SkyLouna/PetLaForme
        /// <summary>
        /// Kills the share pet.
        /// </summary>
        /// <returns>The share pet.</returns>
        /// <param name="petID">Pet identifier.</param>
        /// <param name="userID">User identifier.</param>
        public static ServerPacketConfirmation KillSharePet(int petID, int userID)
        {
            //create new packet kill share pet
            ClientPacketKillSharePet clientPacketKillSharePet = new ClientPacketKillSharePet(petID, userID);

            //send packet to server
            ServerPacketConfirmation serverPacketConfirmation = TCPClient.SendPacket(clientPacketKillSharePet) as ServerPacketConfirmation;

            //if no answer
            if (serverPacketConfirmation == null)
            {
                return(new ServerPacketConfirmation(false, NetworkError.SERVER_UNAVAILABLE));
            }

            return(serverPacketConfirmation);
        }