Пример #1
0
        private bool RegisterGame(OthelloPlayerServer emitter, SaveFile saveFile)
        {
            // Test if the player is known
            if (!IsKnown(emitter))
            {
                throw new Exception("Unknown client");
            }

            // Generate the "savefile"
            LoadRequest loadRequest = new LoadRequest(emitter, saveFile);
            int         requestID   = loadRequest.GetHashCode();

            // Verifiy that the game does not exist
            if (loadedGames.ContainsKey(requestID))
            {
                throw new Exception("Game already loaded");
            }

            // Add it to the list
            loadedGames.TryAdd(requestID, loadRequest);

            // Send the id to the emitter
            emitter.LoadSuccessful(requestID);

            return(true);
        }