Exemplo n.º 1
0
        // --------------------------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// Generates a random set of all characteristics with the total value sum is the given value
        /// </summary>
        /// <param name="sumOfValues">Must be between 6 (where every value = 1) and 30 (where every value is maxed out),
        /// If an invalid value is given, a completely random set is returned</param>
        /// <returns>A Random CharaccteristicSet with the given number as sum of all trained characteristics</returns>
        public static CharacteristicSet RandomCharacteristicSet(int sumOfValues)
        {
            List <Characteristic> list = new List <Characteristic>(BaseCharacteristicList());
            var rand = new Random();
            int min  = (int)Characteristic.MIN_VALUE * 6;
            int max  = (int)Characteristic.MAX_VALUE * 6;

            if (sumOfValues < min || sumOfValues > max)
            {
                sumOfValues = Math.Abs(rand.Next(min, max));
                WfLogger.Log("CharacteristicFactory.RandomCharacteristicSet(int)", LogLevel.DETAILED, "sumOfValues was invalid, new random value = " + sumOfValues);
            }

            // Subtract the base value
            sumOfValues -= 6;

            while (sumOfValues > 0)
            {
                int index = rand.Next(6);

                if (!list[index].IsMaximized())
                {
                    list[index].Training();
                    sumOfValues--;
                }
            }
            WfLogger.Log("CharacteristicFactory.RandomCharacteristicSet(int)", LogLevel.DETAILED, "Create a random CharacteristicSet where the sum of all values is " + sumOfValues);

            return(new CharacteristicSet(list));
        }
Exemplo n.º 2
0
        // --------------------------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// </summary>
        /// <param name="dataToSave"></param>
        public void Save(Type dataToSave)
        {
            _saveData.Add(dataToSave);
            string jsonString      = JsonSerializer.Serialize(_saveData);
            bool   exceptionThrown = false;

            lock (_saveFile)
            {
                try
                {
                    File.WriteAllText(_saveFile, jsonString);
                }
                catch (IOException exc)
                {
                    exceptionThrown = true;
                    WfLogger.Log("SerializationManager.Save(data)", LogLevel.ERROR, "An exception was trown: " + exc.Message);
                }
            }

            if (exceptionThrown)
            {
                WfLogger.Log("SerializationManager.Save(data)", LogLevel.DEBUG, "Couldn't save data");
            }
            else
            {
                WfLogger.Log("SerializationManager.Save(data)", LogLevel.DEBUG, "Saved data: " + File.ReadAllText(_saveFile));
            }
        }
        // --------------------------------------------------------------------------------------------------------------------------------


        public void DeleteGame(PAPIGame game)
        {
            if (game != null)
            {
                int rowNumber = -1;
                foreach (Control control in gameTable.Controls)
                {
                    if (control.Text == game._dateOfCreation.ToString())
                    {
                        rowNumber = gameTable.GetRow(control);
                        break;
                    }
                }

                WfLogger.Log(this, LogLevel.DEBUG, "Remove Game " + game._genre + ", " + game._dateOfCreation
                             + " from List (Number " + rowNumber + ")");
                _savedGames.Remove(game);

                TableLayoutHelper.RemoveRowNumber(gameTable, rowNumber);
            }
            else
            {
                WfLogger.Log(this, LogLevel.WARNING, "No Game was found, which could be removed");
            }
        }
Exemplo n.º 4
0
        // --------------------------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// Set all text in this view to the language which was set in the settings
        /// </summary>
        public override void SetTextToActiveLanguage()
        {
            if (_shownLanguage == PAPIApplication.GetLanguage() && _lastClickTranslated)
            {
                return;
            }
            _shownLanguage = PAPIApplication.GetLanguage();

            using (ResXResourceSet resSet = new ResXResourceSet(GetTranslationFile()))
            {
                Translate(resSet, return_button);
                Translate(resSet, selection_label);
                Translate(resSet, description_label);
                Translate(resSet, game_selection_button);
                Translate(resSet, character_selection_button);
                Translate(resSet, item_selection_button);
                Translate(resSet, vehicle_selection_button);
                Translate(resSet, building_selection_button);
                Translate(resSet, open_creator_button);
                if (selection_description_label.Text == "selection_description")
                {
                    selection_description_label.Text = "";
                }

                if (_lastClicked != null)
                {
                    selection_description_label.Text = TranslatedString(resSet, _lastClicked.Name + "_DESCRIPTION");
                    _lastClickTranslated             = true;
                }
            }

            WfLogger.Log(this, LogLevel.DEBUG, "All text of start view set to " + PAPIApplication.GetLanguage());
        }
Exemplo n.º 5
0
        // --------------------------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// Loads the save file and reads from it
        /// If the file is new, there is an io exception thrown, but then the file is empty anyways, so the program can continue normally
        /// </summary>
        /// <returns>A list of th eread objects of the given type</returns>
        public List <Type> Load()
        {
            string jsonString = "";

            if (!File.Exists(_saveFile))
            {
                _ = CreateFile(_saveFile);
            }
            lock (_saveFile)
            {
                try
                {
                    jsonString = File.ReadAllText(_saveFile);
                }
                catch (IOException exc)
                {
                    WfLogger.Log(this, LogLevel.ERROR, "An Exception was thrown while reading from file (" + _saveFile + "): " + exc.Message
                                 + ", but as this error is only thrown when the file is new and empty, this doesn't matter that much");

                    return(new List <Type>());
                }
            }

            try
            {
                _saveData = JsonSerializer.Deserialize <List <Type> >(jsonString);
            }
            catch (JsonException)
            {
                WfLogger.Log(this, LogLevel.WARNING, "Json File is empty and there is nothing to obtain.");
            }
            return((_saveData == null) ? new List <Type>() : _saveData);
        }
Exemplo n.º 6
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            WfLogger.Log(this, LogLevel.DEBUG, "'Delete' Button was clicked, 'Are you sure?' Prompt opens");
            DeleteGamePromptPopup areYouSurePromt = new DeleteGamePromptPopup();

            areYouSurePromt.Popup(this);
        }
Exemplo n.º 7
0
 public Armour(string _name, uint _basePrice, uint _encumbrance, uint _rarity, ItemConditionEnum _condition,
               Dictionary <ItemQuality, uint> _qualities, List <GenreEnum> _availableGenres, string _descriptionKey, bool _isEquipped,
               Value _soak, Defense _defense)
     : base(_name, _basePrice, _encumbrance, _rarity, _condition, _qualities, _availableGenres, _descriptionKey, _isEquipped, _soak, _defense)
 {
     WfLogger.Log(this, LogLevel.DETAILED, "Created new Armour " + this._nameKey);
 }
        // --------------------------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// Returns true, if the value is already maximized and therefore not applicable for training anymore
        /// </summary>
        /// <returns>True, if value is same as MAX Value</returns>
        public bool IsMaximized()
        {
            bool isMax = (_value >= MAX_VALUE);

            WfLogger.Log(this, LogLevel.DETAILED, this._associatedEnum.ToString() + " maximized: " + isMax);
            return(isMax);
        }
 public Characteristic(CharacteristicEnum _associatedEnum, uint _value, Modification _modification)
 {
     this._associatedEnum = _associatedEnum;
     this._value          = (_value <MIN_VALUE || _value> MAX_VALUE) ? 1 : _value;
     this._modification   = (_modification == null) ? new Modification(0, GameTimeIntervalEnum.NOT_VALID) : _modification;
     WfLogger.Log(this, LogLevel.DETAILED, "Created new Characteristic (" + _associatedEnum.ToString() + ", Value: " + _value + ")");
 }
Exemplo n.º 10
0
 public GameCreationView()
 {
     InitializeComponent();
     WfLogger.Log(this, LogLevel.DEBUG, "Initialized components");
     AddComponents();
     create_and_start_button.Enabled = false;
 }
Exemplo n.º 11
0
        // --------------------------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// Create a default unique rival with a random set of motivations
        /// </summary>
        public UniqueRival() : base()
        {
            _name          = "INVALID_UNIQUE_RIVAL";
            _motivationSet = MotivationFactory.RandomMotivationSet();

            WfLogger.Log(this, LogLevel.DETAILED, "Created new Unique Rival from default");
        }
Exemplo n.º 12
0
        // Functionality removed, but code is still there for reference

        /* private void addPlayerButton_Click(object sender, EventArgs e)
         * {
         *   WfLogger.Log(this, LogLevel.DEBUG, "Add new Player Button was clicked, open the Player Search Popup");
         *   ViewController.playerSearchPopup.Popup(this);
         *
         * }*/

        private void genreDropdown_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (genreDropdown.SelectedIndex)
            {
            case 0:
                _cachedGenre = GenreEnum.NUCLEAR_FALLOUT;
                break;

            case 1:
                _cachedGenre = GenreEnum.MEDIEVAL_FANTASY;
                break;

            case 2:
                _cachedGenre = GenreEnum.MAGICAL_WORLD;
                break;

            case 3:
                _cachedGenre = GenreEnum.SPACE_OPERA;
                break;

            default:
                _cachedGenre = GenreEnum.NOT_VALID;
                break;
            }
            if (_cachedGenre != GenreEnum.NOT_VALID)
            {
                create_and_start_button.Enabled = true;
            }
            genre_description.Text = _genreDescriptions[_cachedGenre];

            WfLogger.Log(this, LogLevel.DEBUG, "Genre " + _cachedGenre + " was selected in dropdown");
        }
        public CharacteristicSet(List <Characteristic> _characteristicList)
        {
            if (_characteristicList == null)
            {
                _characteristicList = new List <Characteristic>();
            }
            this._characteristicList = new List <Characteristic>();

            List <CharacteristicEnum> missing = new List <CharacteristicEnum>()
            {
                CharacteristicEnum.BRAWN, CharacteristicEnum.AGILITY, CharacteristicEnum.INTELLECT,
                CharacteristicEnum.CUNNING, CharacteristicEnum.WILLPOWER, CharacteristicEnum.PRESENCE
            };

            foreach (Characteristic characteristic in _characteristicList)
            {
                if (missing.Contains(characteristic._associatedEnum) && characteristic._value >= Characteristic.MIN_VALUE && characteristic._value <= Characteristic.MAX_VALUE)
                {
                    this._characteristicList.Add(characteristic);
                    missing.Remove(characteristic._associatedEnum);
                }
            }

            foreach (CharacteristicEnum charaEnum in missing)
            {
                this._characteristicList.Add(new Characteristic(charaEnum, 1, null));
            }

            WfLogger.Log(this, LogLevel.DETAILED, "CharacteristicSet was created");
        }
Exemplo n.º 14
0
        // --------------------------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// Creates a new invalid wearable Item
        /// </summary>
        public WearableItem() : base()
        {
            _soak    = new Value();
            _defense = new Defense();

            WfLogger.Log(this, LogLevel.DETAILED, "Created new invalid WearableItem from default");
        }
Exemplo n.º 15
0
        // --------------------------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// Calls the CTOR of PAPIGame and creates a new game with the given genre and the current player as game master
        /// </summary>
        /// <param name="genre"></param>
        public static void CreateNewGame(GenreEnum genre, string id)
        {
            _runningGame = new PAPIGame(genre, PAPIApplication.GetPlayer(), null, DateTime.Now, DateTime.Now, null, id);
            SaveFileManager.Save(_runningGame);

            WfLogger.Log("PAPIApplication.CreateNewGame", LogLevel.DEBUG, "Created new Game");
        }
Exemplo n.º 16
0
        public PAPICharacter(string _archetype, Species _species, Value _soak, ThresholdValue _health, Defense _defense, CharacteristicSet _characteristics,
                             Equipment _equipment, Inventory _inventory, List <PAPISkill> _skillSet, List <Ability> _abilities, Career _career, CharacterAppearance _appearance,
                             GenderEnum _gender, List <GenderEnum> _genderPreferences)
        {
            this._archetype       = (_archetype == null || _archetype == "") ? "Townspeople" : _archetype;
            this._species         = (_species == null) ? SpeciesHandler.GetSpecies(SpeciesEnum.HUMAN) : _species;
            this._soak            = (_soak == null) ? new Value(0, null) : _soak;
            this._characteristics = (_characteristics == null) ? new CharacteristicSet() : _characteristics;
            this._health          = (_health == null) ?
                                    new ThresholdValue(SpeciesHandler.GetInitialHealth(this._species._enum)) : _health;
            this._defense           = (_defense == null) ? new Defense(0, null, 0, null) : _defense;
            this._equipment         = (_equipment == null) ? new Equipment(null, null, null, null) : _equipment;
            this._inventory         = (_inventory == null) ? new Inventory(null, null) : _inventory;
            this._skillSet          = (_skillSet == null) ? new List <PAPISkill>() : _skillSet;
            this._abilities         = (_abilities == null) ? new List <Ability>() : _abilities;
            this._career            = _career;
            this._appearance        = (_appearance == null) ? new CharacterAppearance(SpeciesHandler.GetAverageAppearance(this._species._enum)) : _appearance;
            this._gender            = _gender;
            this._genderPreferences = (_genderPreferences == null || _genderPreferences.Count == 0) ? new List <GenderEnum>()
            {
                GenderEnum.NONE
            } : _genderPreferences;

            WfLogger.Log(this, LogLevel.DETAILED, "Created new Character (" + this._species._enum +
                         " " + this._archetype + ")");
        }
Exemplo n.º 17
0
        public Player(string _name, string _id)
        {
            this._name = (_name == null || _name == "") ? "NOT_VALID_FROM_CTOR" : _name;
            this._id   = (_id == null || _id == "") ? PAPIApplication.GetUniqueId() : _id;

            WfLogger.Log(this, LogLevel.DETAILED, "Created new Player " + _name);
        }
Exemplo n.º 18
0
 public OptionsView() : base()
 {
     InitializeComponent();
     WfLogger.Log(this, LogLevel.DEBUG, "Initialized components");
     _buttons.Add(return_button);
     SetButtonDesign();
 }
Exemplo n.º 19
0
        private void AddComponents()
        {
            _buttons.Add(cancelButton);
            _buttons.Add(deleteButton);
            _buttons.Add(startButton);

            playerCharacterPanel.AutoSize    = true;
            playerCharacterPanel.ColumnCount = 3;
            playerCharacterPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 24F));
            playerCharacterPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 24F));
            playerCharacterPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 24F));
            playerCharacterPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 24F));
            playerCharacterPanel.Controls.Add(playerNameLabel, 0, 0);
            playerCharacterPanel.Controls.Add(characterNameLabel, 1, 0);
            playerCharacterPanel.Controls.Add(speciesLabel, 2, 0);
            playerCharacterPanel.Controls.Add(careerLabel, 3, 0);
            playerCharacterPanel.RowCount = 1;

            playerCharacterPanel.GrowStyle = TableLayoutPanelGrowStyle.AddRows;

            ShowPlayers();

            WfLogger.Log(this, LogLevel.DEBUG, "Added all components");
            SetTextToActiveLanguage();
        }
Exemplo n.º 20
0
        // --------------------------------------------------------------------------------------------------------------------------------

        public override void SetTextToActiveLanguage()
        {
            if (_shownLanguage == PAPIApplication.GetLanguage() && _cachedPlayerName == PAPIApplication.GetPlayer()._name)
            {
                return;
            }
            _cachedPlayerName = PAPIApplication.GetPlayer()._name;

            using (ResXResourceSet resSet = new ResXResourceSet(GetTranslationFile()))
            {
                Translate(resSet, language_label);
                Translate(resSet, design_label);
                Translate(resSet, return_button);
                Translate(resSet, player_name_label);
                Translate(resSet, player_id_label);
                playerName_inputField.Text = _cachedPlayerName;
                player_id_textbox.Text     = PAPIApplication.GetPlayer()._id;
                design_dropdown.Items[0]   = TranslatedEnum(resSet, DesignEnum.PAPYRUS);
                design_dropdown.Items[1]   = TranslatedEnum(resSet, DesignEnum.DIGITAL);
                design_dropdown.Items[2]   = TranslatedEnum(resSet, DesignEnum.NOVEL);
                language_dropdown.Items[0] = TranslatedEnum(resSet, LanguageEnum.ENGLISH);
                language_dropdown.Items[1] = TranslatedEnum(resSet, LanguageEnum.GERMAN);
            }
            WfLogger.Log(this, LogLevel.DEBUG, "All text set to " + PAPIApplication.GetLanguage());
        }
Exemplo n.º 21
0
        // --------------------------------------------------------------------------------------------------------------------------------

        private void open_creator_button_Click(object sender, EventArgs e)
        {
            WfLogger.Log(this, LogLevel.DEBUG, "The 'Open Creator' Button was clicked");

            if (_lastClicked == game_selection_button)
            {
                WfLogger.Log(this, LogLevel.WARNING, "Open Game Selection View not yet implemented.");
                ViewController.gameSelectionView.Open(this);
            }
            else if (_lastClicked == character_selection_button)
            {
                WfLogger.Log(this, LogLevel.WARNING, "Open Character Selection View not yet implemented.");
                //ViewController.characterSelectionView.Open();
            }
            else if (_lastClicked == item_selection_button)
            {
                WfLogger.Log(this, LogLevel.WARNING, "Open Item Selection View not yet implemented.");
                //ViewController.itemSelectionView.Open();
            }
            else if (_lastClicked == vehicle_selection_button)
            {
                WfLogger.Log(this, LogLevel.WARNING, "Open Vehicle Selection View not yet implemented.");
                //ViewController.vehicleSelectionView.Open();
            }
            else if (_lastClicked == building_selection_button)
            {
                WfLogger.Log(this, LogLevel.WARNING, "Open Building Selection View not yet implemented.");
                //ViewController.buildingSelectionView.Open();
            }
        }
Exemplo n.º 22
0
        // --------------------------------------------------------------------------------------------------------------------------------

        private void languageDropdown_SelectedIndexChanged(object sender, EventArgs e)
        {
            LanguageEnum chosenLanguage;

            switch (language_dropdown.SelectedIndex)
            {
            case 0:
                chosenLanguage = LanguageEnum.ENGLISH;
                break;

            case 1:
                chosenLanguage = LanguageEnum.GERMAN;
                break;

            default:
                chosenLanguage = LanguageEnum.ENGLISH;
                break;
            }
            if (chosenLanguage != PAPIApplication.GetLanguage())
            {
                PAPIApplication.SetLanguage(chosenLanguage);
                WfLogger.Log(this, LogLevel.DEBUG, "Set language to " + PAPIApplication.GetLanguage() + " in dropdown");
                SetTextToActiveLanguage();
            }
        }
Exemplo n.º 23
0
        public Inventory(Dictionary <PAPIItem, uint> _inventory, Backpack _backpack)
        {
            this._inventory = (_inventory == null) ? new Dictionary <PAPIItem, uint>() : _inventory;
            this._backpack  = _backpack;

            WfLogger.Log(this, LogLevel.DETAILED, "Creates new Inventory");
        }
Exemplo n.º 24
0
        // --------------------------------------------------------------------------------------------------------------------------------

        private void designDropdown_SelectedIndexChanged(object sender, EventArgs e)
        {
            DesignEnum chosenDesign = PAPIApplication.GetDesign();

            switch (design_dropdown.SelectedIndex)
            {
            case 0:
                chosenDesign = DesignEnum.PAPYRUS;
                break;

            case 1:
                chosenDesign = DesignEnum.DIGITAL;
                break;

            case 2:
                chosenDesign = DesignEnum.NOVEL;
                break;

            default:
                break;
            }
            if (chosenDesign != PAPIApplication.GetDesign())
            {
                PAPIApplication.SetDesign(chosenDesign);
                WfLogger.Log(this, LogLevel.DEBUG, "Set design to " + PAPIApplication.GetDesign() + " in dropdown");
                SetDesign();
                SetButtonDesign();
            }
        }
Exemplo n.º 25
0
        // --------------------------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// Source: https://codereview.stackexchange.com/questions/49158/writing-to-file-in-a-thread-safe-manner
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        private async Task CreateFile(string fileName)
        {
            int       timeOut   = 100;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            while (true)
            {
                try
                {
                    lock (lockObj)
                    {
                        File.Create(fileName);
                        WfLogger.Log(this, LogLevel.INFO, "Created file: " + fileName);
                    }
                    break;
                }
                catch
                {
                    WfLogger.Log(this, LogLevel.ERROR, "Creation of file not possible");
                }
                if (stopwatch.ElapsedMilliseconds > timeOut)
                {
                    WfLogger.Log(this, LogLevel.WARNING, "Timeout while trying create file");
                    break;
                }

                await Task.Delay(5);
            }
            stopwatch.Stop();
        }
 public PlayerSearchPopup()
 {
     InitializeComponent();
     WfLogger.Log(this, LogLevel.DEBUG, "Initialized components");
     addPlayerButton.Visible = false;
     addPlayerButton.Enabled = false;
 }
        // --------------------------------------------------------------------------------------------------------------------------------


        public override void SetTextToActiveLanguage()
        {
            if (_shownLanguage == PAPIApplication.GetLanguage())
            {
                return;
            }

            using (ResXResourceSet resSet = new ResXResourceSet(GetTranslationFile()))
            {
                Translate(resSet, saved_games_label);
                Translate(resSet, return_button);
                Translate(resSet, load_game_button);
                Translate(resSet, game_creator_button);
                Translate(resSet, date_game_creation_label);
                Translate(resSet, genre_label);
                Translate(resSet, date_last_save_label);


                ShowSavedGamesTranslation(resSet);

                /*for (int row = 0; row < _savedGames.Count; ++row)
                 * {
                 *  gameTable.Controls.Add(new Label()
                 *  {
                 *      Text = TranslatedString(resSet, "genre_" + _savedGames[row]._genre.ToString().ToLower()),
                 *      Anchor = AnchorStyles.Left | AnchorStyles.Top,
                 *      Width = 250
                 *  }, 0, row + 1);
                 * }*/
            }
            WfLogger.Log(this, LogLevel.DEBUG, "All text set to " + PAPIApplication.GetLanguage());
        }
 private void SearchPlayer()
 {
     while (attemptCounter < MAX_SEARCH_TIME)
     {
         if (PendingMessages.waitingPlayers.Count > 0)
         {
             WfLogger.Log(this, LogLevel.DEBUG, "Pending Player Requests found: " + PendingMessages.waitingPlayers.Count);
             this.foundPlayerNameTextbox.Text = PendingMessages.waitingPlayers[0]._name;
             addPlayerButton.Visible          = true;
             addPlayerButton.Enabled          = true;
             searchPlayerButton.Visible       = false;
             return;
         }
         else
         {
             WfLogger.Log(this, LogLevel.DEBUG, "No Pending Player Requests found... trying again (Attempt number: " + attemptCounter + ")");
             searchPlayerButton.Visible = false;
             Thread.Sleep(1000);
             attemptCounter++;
             SearchPlayer();
             searchPlayerButton.Visible = true;
             return;
         }
     }
 }
 /// <summary>
 /// Loads saved games and adds all components/controls to the view
 /// </summary>
 public GameSelectionView()
 {
     _savedGames = SaveFileManager.LoadGames();
     InitializeComponent();
     WfLogger.Log(this, LogLevel.DEBUG, "Initialized SelectGameView");
     AddComponents();
 }
Exemplo n.º 30
0
        private static void ListenForRequests()
        {
            var thread = new Thread(() =>
            {
                while (true)
                {
                    const int bytesize = 1024;

                    string message = null;
                    byte[] buffer  = new byte[bytesize];

                    var sender = listener.AcceptTcpClient();
                    sender.GetStream().Read(buffer, 0, bytesize);

                    // Read the message and perform different actions
                    message = CleanMessage(buffer);

                    WfLogger.Log("GameMasterPAPI.Server.PAPIServer", LogLevel.DEBUG, "Received a TCP connection from " + sender.GetType() + " (Message = " + message + ")");

                    // Save the data sent by the client;
                    // Deserialize

                    byte[] response = HandleRequest(message);
                    sender.GetStream().Write(response, 0, response.Length); // Send the response
                }
            });

            thread.Start();
        }