public static XDMessagingClient WithAmazonSettings(this XDMessagingClient client, RegionEndPoint awsRegionEndPoint) { var settings = GetSettings(); settings.RegionEndPoint = awsRegionEndPoint; return(client); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); uniqueInstanceName = $"{Environment.MachineName}-{Handle}"; client = new XDMessagingClient().WithAmazonSettings(RegionEndPoint.EUWest1); if (!client.HasValidAmazonSettings()) { MessageBox.Show("Azazon AWS crendentials not set. Enter your credentials in the app.config.", "Missing AWS Crendentials", MessageBoxButtons.OK, MessageBoxIcon.Warning); propagateCheck.CheckState = CheckState.Unchecked; propagateCheck.Enabled = false; mailRadio.Enabled = false; } var tooltips = new ToolTip(); tooltips.SetToolTip(sendBtn, "Broadcast message on Channel 1\r\nand Channel2"); tooltips.SetToolTip(groupBox1, "Choose which channels\r\nthis instance will\r\nlisten on"); tooltips.SetToolTip(Mode, "Choose which mode\r\nto use for sending\r\nand receiving"); UpdateDisplayText( "Launch multiple instances of this application to demo interprocess communication. Run multiple instances on different machines to demo network propogation.\r\n", Color.Gray); Text += $" - {uniqueInstanceName}"; InitializeMode(XDTransportMode.HighPerformanceUI); var message = $"{uniqueInstanceName} has joined"; broadcast.SendToChannel("Status", message); }
public static XDMessagingClient WithAmazonUniqueKey(this XDMessagingClient client, string uniqueAppKey) { var settings = GetSettings(); settings.UniqueAppKey = uniqueAppKey; return(client); }
/// <summary> /// Broadcast a message that the service has started. /// </summary> /// <param name = "args"></param> protected override void OnStart(string[] args) { isTraceEnabled = true; client = new XDMessagingClient().WithAmazonSettings(RegionEndPoint.EUWest1); listener = client.Listeners.GetListenerForMode(XDTransportMode.Compatibility); listener.MessageReceived += OnMessageReceived; listener.RegisterChannel("BinaryChannel1"); listener.RegisterChannel("BinaryChannel2"); //only the following mode is supported in windows services broadcast = client.Broadcasters.GetBroadcasterForMode(XDTransportMode.Compatibility); broadcast.SendToChannel("Status", "Test Service has started: Send STOP on Channel 1/2 to halt timer. Send START to Channel 1/2 to restart."); cancelToken = new CancellationTokenSource(); Task.Factory.StartNew(() => { while (!cancelToken.IsCancellationRequested) { if (isTraceEnabled) { broadcast.SendToChannel("Status", "The time is: " + DateTime.Now.ToString("f")); Thread.Sleep(5000); } } }); }
public static XDMessagingClient WithAmazonSettings(this XDMessagingClient client, string accessKey, string accessSecret) { var settings = GetSettings(); settings.AccessKey = accessKey; settings.SecretKey = accessSecret; return(client); }
public static bool HasValidAmazonSettings(this XDMessagingClient client) { var settings = GetSettings(); return(settings.IsValid); }
public static XDMessagingClient WithAmazonSettings(this XDMessagingClient client, string accessKey, string accessSecret, RegionEndPoint awsRegionEndPoint) { return(client.WithAmazonSettings(accessKey, accessSecret).WithAmazonSettings(awsRegionEndPoint)); }
private void Form1_Load(object sender, EventArgs e) { /* * Console Initialization */ Globals.console_attached = false; #if DEBUG NativeMethods.AllocConsole(); Globals.console_attached = true; Globals.CConsole = new CreativityConsole(); Console.SetOut(Globals.CConsole); Console.WriteLine("INFO#Modulous Manager ON " + Assembly.GetExecutingAssembly().GetName().Version); BringToFront(); #endif if (!File.Exists(Path.Combine(Application.StartupPath, "lock.json"))) { ProcessStartInfo info = new ProcessStartInfo(Path.Combine(Application.StartupPath, "ModulousBootStraper.exe")); info.UseShellExecute = true; info.Verb = "runas"; string asd = "dummy"; Console.WriteLine(Path.Combine(Application.StartupPath, "ModulousBootStraper.exe")); try { Process.Start(info); } catch (Win32Exception ex) { if (ex.NativeErrorCode == 1223) { TopMostMessageBox.Show("You must run the program as admin"); Environment.Exit(0); } } File.WriteAllText(Path.Combine(Application.StartupPath, "lock.json"), asd); } #region Manager update checking string version_file_path = Path.Combine(Application.StartupPath, "version.json"); try { VersionInfo online_version_info = VersionInfo.get_version_info_from_api(); VersionInfo local_version_info = VersionInfo.FromFile(version_file_path); if (online_version_info.version > local_version_info.version) { //holy shit we are outdated f**k DialogResult dialog = TopMostMessageBox.Show("Your Mod Manager is outdated, do you want to update?, it will only take a few seconds at most.", "Outdated Mod Manager detected", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { if (File.Exists(Path.Combine(Application.StartupPath, "updater.exe"))) { File.Delete(Path.Combine(Application.StartupPath, "updater.dat")); } File.Copy(Path.Combine(Application.StartupPath, "updater.dat"), Path.Combine(Application.StartupPath, "updater.exe")); Process.Start(Path.Combine(Application.StartupPath, "updater.exe")); Application.Exit(); } } } catch (Exception) { throw; } #endregion #region Async Command Listening XDMessagingClient client = new XDMessagingClient(); IXDListener listener = client.Listeners.GetListenerForMode(XDTransportMode.HighPerformanceUI); listener.RegisterChannel("modulousmmintercoms"); listener.MessageReceived += (o, es) => { if (es.DataGram.Channel == "modulousmmintercoms") { string[] command = es.DataGram.Message.Split('#'); switch (command[0]) { case "install": int id; if (int.TryParse(command[1], out id)) { try { OnlineMod mod = OnlineMod.get_mod_from_API(id); LocalMod local_mod = mod.get_local_mod(); Console.WriteLine("GOTCHA!!!!"); if (!local_mod.is_installed) { install_mod_ui(local_mod); } } catch (Exception ex) { MessageBox.Show( "The mod you are trying to install does not exist, check the console for details.", "API error", MessageBoxButtons.OK, MessageBoxIcon.Error); Console.WriteLine("ERR#" + ex.Message); Console.WriteLine("ERR#" + ex.StackTrace); } } break; } } }; #endregion //loads art TempFolder.clean_temp_folder(); reload_art(); //HACK: //we need to trigger a size change callback var mods_size = mods_list_view.Width; mods_list_view.Width = 10; mods_list_view.Width = mods_size; var status_size = status_list_view.Width; status_list_view.Width = 10; status_list_view.Width = status_size; /* * Lua initialization */ var state = new Lua(); state.LoadCLRPackage(); #region Configuration /* * Configuration Initialization */ Console.WriteLine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); var config_file_path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Modulous/config.json"); Console.WriteLine(config_file_path); if ( File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Modulous/config.json"))) { try { Globals.config_file = new ConfigFile().FromFile(config_file_path); } catch (Exception ex) { File.Delete(config_file_path); Globals.config_file = new ConfigFile(); Console.WriteLine("ERR#" + ex.StackTrace); Console.WriteLine("ERR#" + ex.Message); File.WriteAllText(config_file_path, JsonConvert.SerializeObject(Globals.config_file, Formatting.Indented)); } } else if (Directory.Exists(Path.GetDirectoryName(config_file_path))) { Globals.config_file = new ConfigFile(); File.WriteAllText(config_file_path, JsonConvert.SerializeObject(Globals.config_file, Formatting.Indented)); } else { Directory.CreateDirectory(Path.GetDirectoryName(config_file_path)); Globals.config_file = new ConfigFile(); File.WriteAllText(config_file_path, JsonConvert.SerializeObject(Globals.config_file, Formatting.Indented)); } if (!Directory.Exists(Globals.config_file.sd_card_location)) { MessageBox.Show("You must select your SD Card or mod installation folder.", "Select your SDCard", MessageBoxButtons.OK, MessageBoxIcon.Information); } while (Globals.config_file.sd_card_location == null) { var folder_browse = new FolderBrowserDialog(); folder_browse.Description = "Select a new SD folder"; folder_browse.ShowDialog(); if (folder_browse.SelectedPath == "") { MessageBox.Show("You must select a new SD Card folder.", "SDCard Error", MessageBoxButtons.OK, MessageBoxIcon.Error); SDManager.set_sd_card(folder_browse.SelectedPath); continue; } Globals.config_file.sd_card_location = folder_browse.SelectedPath; } File.WriteAllText(config_file_path, JsonConvert.SerializeObject(Globals.config_file, Formatting.Indented)); SDManager.set_sd_card(Globals.config_file.sd_card_location); #endregion #region Safe Checks Console.WriteLine("INFO#Checking if " + Path.Combine(SDCard.sd_card_path, "private/wii/app/RSBE/pf") + " Exists"); while(!Directory.Exists(Path.Combine(SDCard.sd_card_path, "private/wii/app/RSBE/pf")) && !Directory.Exists(Path.Combine(SDCard.sd_card_path, "projectm"))) { NativeMethods.SetForegroundWindow(this.Handle); DialogResult dialogResult = TopMostMessageBox.Show("There doesn't seem to be a valid Gecko Brawl/Project M installation in your SD Card, click retry to retry or cancel to select a new SDCard folder", "", MessageBoxButtons.RetryCancel); if (dialogResult == DialogResult.Retry) { continue; } else { var folder_browse = new FolderBrowserDialog(); folder_browse.Description = "Select a new SD folder"; selectsderr: folder_browse.ShowDialog(); if (folder_browse.SelectedPath == "") { MessageBox.Show("You must select a new SD Card folder.", "SDCard Error", MessageBoxButtons.OK, MessageBoxIcon.Error); goto selectsderr; } Globals.config_file.sd_card_location = folder_browse.SelectedPath; SDManager.set_sd_card(folder_browse.SelectedPath); File.WriteAllText(config_file_path, JsonConvert.SerializeObject(Globals.config_file, Formatting.Indented)); } } #endregion if (!Directory.Exists(SDCard.sd_card_mod_store_path)) { Directory.CreateDirectory(SDCard.sd_card_mod_store_path); } #region Online Mod Gathering reload_mods(); #endregion #region Upate Checking /* foreach (ListViewItem item in mods_list_view.Items) { LocalMod mod = (LocalMod)item.Tag; if (mod.is_installed && mod.is_online) { ModVersion version = mod.online_mod.versions[0]; float version_number; if (float.TryParse(version.friendly_version, out version_number)) { if (version_number > mod.installed_mod.version) { temp_folder_busy = true; Directory.CreateDirectory(ModulousLib.Globals.temporary_path); if (mods_list_view.SelectedItems == null && mods_list_view.SelectedItems[0].SubItems[4].Text == "Not Installed") { return; } var online_mod = mod.online_mod; var web_client = new WebClient(); var file_path = ""; var download_item = new ListViewItem(mod.installed_mod.name); download_item.SubItems.Add("Downloading"); download_item.SubItems.Add(""); download_item = status_list_view.Items.Add(item); web_client.DownloadProgressChanged += (s, ex) => { download_item.SubItems[2].Text = ex.ProgressPercentage.ToString() + "/100"; }; web_client.DownloadFileCompleted += (s, ex) => { item.SubItems[1].Text = "Downloaded"; OnlineMod.update_mod_from_file(file_path, mod.installed_mod.id); temp_folder_busy = false; }; var file_url = new Uri(new Uri(ModulousLib.Globals.site_url), mod.online_mod.versions[0].download_path).ToString(); var file_name = ""; web_client.DownloadData(file_url); if (!String.IsNullOrEmpty(web_client.ResponseHeaders["Content-Disposition"])) { file_name = web_client.ResponseHeaders["Content-Disposition"].Substring( web_client.ResponseHeaders["Content-Disposition"].IndexOf("filename=") + 10) .Replace("\"", ""); file_path = Path.Combine(ModulousLib.Globals.temporary_path, file_name); } Console.WriteLine(file_path); //web_client.DownloadFileAsync(), ModulousLib.Globals.temporary_path); web_client.DownloadFileAsync(new Uri(file_url), file_path); } } } } */ #endregion //OnlineMod.install_mod_from_file(@"E:\Modulous\mod.zip"); }
private static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); TempFolder.clean_temp_folder(); PreRunModQuery.is_mod_queried = false; bool is_another_instance_running = false; Process[] running_processes = Process.GetProcessesByName("ModulousMM"); foreach (Process process in running_processes) { if (!process.ProcessName.Contains("vshost") && process.Id != Process.GetCurrentProcess().Id) { is_another_instance_running = true; } } foreach (string arg in args) { if (is_another_instance_running ) { if (arg.Contains("modulous")) { string[] arg_data = arg.Replace(@"modulous://", "").Split('/'); string command = arg_data[0]; switch (command) { case "install": int id; if (int.TryParse(arg_data[1], out id)) { if (is_another_instance_running) { XDMessagingClient client = new XDMessagingClient(); IXDBroadcaster broadcaster = client.Broadcasters.GetBroadcasterForMode(XDTransportMode.HighPerformanceUI); broadcaster.SendToChannel("modulousmmintercoms", "install#" + arg_data[1].ToString()); Environment.Exit(0); } else { PreRunModQuery.is_mod_queried = true; PreRunModQuery.queried_mod = id; } } break; default: if (is_another_instance_running) { Environment.Exit(0); } break; } } } else { if ( is_another_instance_running) { Environment.Exit(0); } } } if (is_another_instance_running) { Environment.Exit(0); } Application.Run(new MainForm()); }