/// <summary> /// Constructs a new GameNetworkListener object and initializes all values. /// </summary> /// <param name="customPort">The port to run the listener on</param> /// <param name="contentPackages">The content packages to be streamed to users on connection.</param> public GameNetworkListener(int customPort, List<ContentPackage> contentPackages) { WebUtility = new WebServiceClientUtility(); if (customPort <= 0) { customPort = GameServerConfiguration.DefaultGamePort; } Agent = new NetworkAgent(NetworkAgentRoleEnum.Server, GameServerConfiguration.ApplicationID, customPort); Agent.OnConnected += Agent_OnConnectionEstablished; Agent.OnDisconnected += Agent_OnDisconnected; this._contentPackages = contentPackages; _contentPackageNames = new List<string>(); _contentPackagePaths = new List<string>(); if (contentPackages != null) { foreach (ContentPackage package in contentPackages) { _contentPackageNames.Add(package.FileName); _contentPackagePaths.Add(DirectoryPaths.ContentPackageDirectoryPath + package.FileName); } } FileExtensionFactory = new FileExtensionFactory(); FileTransferClients = new Dictionary<NetConnection, FileTransferProgress>(); Model = new GameNetworkListenerModel(); }
private void CustomInitialize() { WebUtility = new WebServiceClientUtility(); FileExtensionFactory = new FileExtensionFactory(); MissingFiles = new List<string>(); AwesomiumWebView.DocumentReady += OnDocumentReady; WinterEngineService.InitializeNetworkClient(); WinterEngineService.NetworkClient.OnPacketReceived += NetworkClient_OnPacketReceived; }
/// <summary> /// Finds and returns the path to the database file in a directory. /// Returns "" if no file is found. /// </summary> /// <param name="directoryPath">The path to the directory that this method will check.</param> /// <returns></returns> public string GetDatabaseFileInDirectory(string directoryPath) { FileExtensionFactory factory = new FileExtensionFactory(); DirectoryInfo directoryInfo = new DirectoryInfo(directoryPath); FileInfo[] fileInfo = directoryInfo.GetFiles(); string extension = factory.GetFileExtension(FileTypeEnum.Database); string databaseFilePath = ""; foreach (FileInfo file in fileInfo) { if (file.Extension == extension) { databaseFilePath = file.FullName; break; } } return databaseFilePath; }
/// <summary> /// Checks the ContentPackages directory for the required content packs that the module uses. /// If any of them are missing, a pop-up window will display and this method will return false. /// </summary> /// <returns></returns> public bool CheckForMissingContentPackages() { List<string> missingContentPackages; List<string> fileContentPackages = new List<string>(); List<string> moduleContentPackages; // Retrieve the existing content packages (ones which are in the ContentPackages directory) FileExtensionFactory factory = new FileExtensionFactory(); string[] filePaths = Directory.GetFiles(DirectoryPaths.ContentPackageDirectoryPath, "*" + factory.GetFileExtension(FileTypeEnum.ContentPackage)); foreach (string path in filePaths) { fileContentPackages.Add(Path.GetFileName(path)); } // Retrieve the required content packages (ones which are attached to the module) using (ContentPackageRepository repo = new ContentPackageRepository()) { IEnumerable<ContentPackage> contentPackages = repo.GetAll(); moduleContentPackages = (from package in contentPackages select package.FileName).ToList(); } // Determine which content packages do not exist on disk that are required by this module. missingContentPackages = moduleContentPackages.Except(fileContentPackages).ToList(); if (missingContentPackages.Count > 0) { string errorMessage = "Unable to locate the following content packages:\n\n"; foreach (string current in missingContentPackages) { errorMessage += current + "\n"; } errorMessage += "\nPlease place the missing content packages in the ContentPacks folder and try again."; MessageBox.Show(errorMessage, "Missing Content Packages", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } else { return true; } }
private void Window_Initialized(object sender, EventArgs e) { Model = new ContentPackageXML(); ExtensionFactory = new FileExtensionFactory(); SaveFilePrompt = new SaveFileDialog(); OpenFilePrompt = new OpenFileDialog(); lstAddedResources.DataContext = Model.ResourceList; }
private void InitializeOpenFileDialog() { FileExtensionFactory fileExtensionFactory = new FileExtensionFactory(); OpenFile.Filter = fileExtensionFactory.BuildModuleFileFilter(); OpenFile.AddExtension = true; OpenFile.Title = "Open Module"; OpenFile.Multiselect = false; OpenFile.FileOk += LoadModule; }