public static void Main() { var client = new IpcClient("ExamplePipeName"); client.Connected += () => Console.WriteLine("Connected"); client.Disconnected += () => Console.WriteLine("Disconnected"); client.Message += message => Console.WriteLine($"Message Received: {message}"); client.Connect(); Thread.Sleep(1000); client.Send("Client 1"); Thread.Sleep(1000); client.Send("Client 2"); Thread.Sleep(1000); client.Send("Client 3"); Thread.Sleep(10000); client.Stop(); Console.WriteLine("End"); }
internal UIClient() { _client.Initialize(12345); Console.WriteLine("Started client."); var rep = _client.Send("ConfigInitialized"); }
private void SetButtonStatus() { var rep = c.Send("serviceStatus"); WindowsCommon.IPC.Status m = JsonConvert.DeserializeObject <WindowsCommon.IPC.Status>(rep); if (m.ServiceRunning) { ButtonStop.Enabled = true; ButtonStart.Enabled = false; } else { ButtonStop.Enabled = false; ButtonStart.Enabled = true; } }
public NtStatus OnRequestFileOpen(string filepath) { switch (_config.ProtectMode) { case ProtectMode.SandboxAll: { Task.Run(() => { try { return(_ipcClient.Send(filepath)); } catch (Exception e) { return(null); } }); return(DokanResult.FileNotFound); } case ProtectMode.ScanAll: { return(DokanResult.AccessDenied); } case ProtectMode.ScanThenSandbox: { return(DokanResult.AccessDenied); } default: return(DokanResult.AccessDenied); } }
public void Chat_Client(int port) { try { Task.Factory.StartNew(() => { var c = new IpcClient(); c.Initialize(port); listBox1.Items.Add("Started client."); var rep = c.Send("Hello from client"); listBox1.Items.Add(rep); }); //while(true) //{ // Thread.Sleep(1000); //} } catch (Exception ex) { listBox1.Items.Add(ex.Message); } //Console.WriteLine(); }
private void SendIpcMessage(PatcherIpcEnvelope envelope) { try { _client.Send(PatcherMain.Base64Encode(JsonConvert.SerializeObject(envelope, Formatting.Indented, XIVLauncher.PatchInstaller.PatcherMain.JsonSettings))); } catch (Exception e) { Log.Error(e, "[PATCHERIPC] Failed to send message."); } }
private static void SendMessage(string arguments) { if (string.IsNullOrEmpty(arguments)) { return; } var c = new IpcClient(); c.Initialize(12345); c.Send(arguments); }
public string radioSend(string msg, FConstants.FreyaLogLevel loglevel = FConstants.FreyaLogLevel.Normal) { if (radioClient != null) { return(radioClient.Send(JsonConvert.SerializeObject(new FMsg { Type = "MSG", Data = msg, Loglevel = loglevel }))); } else { return("Proxy radioClient is null."); } }
private static void Main() { var c = new IpcClient(); c.Initialize(12345); Console.WriteLine("Started client."); var rep = c.Send("Hello"); Console.WriteLine("Received: " + rep); while (true) { Thread.Sleep(1000); } }
/// <summary> /// Creates an IPC client and sends a message to the already /// running instance of Quaver /// </summary> private static void SendToRunningInstanceIpc(string[] messages) { try { var c = new IpcClient(); c.Initialize(IpcPort); foreach (var message in messages) { c.Send(message); } } catch (Exception e) { Console.WriteLine(e.ToString()); } }
public static void StartIpcCommunication(JavaScriptBridge javaScriptBridge, int serverPort, int clientPort) { var server = new IpcServer(); server.Start(serverPort); server.ReceivedRequest += (sender, e) => { var deserialized = JsonConvert.DeserializeObject <WebUiMessageEventArgs>(e.Request); javaScriptBridge.SendMessageToOpenProject( deserialized.MessageType, deserialized.TrackingId, deserialized.MessagePayload); }; var client = new IpcClient(); client.Initialize(clientPort); javaScriptBridge.OnWebUiMessageReceived += (s, e) => client.Send(JsonConvert.SerializeObject(e)); }
static void Main(string[] args) { Console.SetWindowSize(60, 10); var c = new IpcClient(); c.Initialize(12345); Console.WriteLine("Started client"); try { var rep = c.Send(args[0]); Console.WriteLine("Received: " + rep); } catch (Exception e) { Console.WriteLine("Error: did you start the server with admin privileges?"); Console.WriteLine("Press any key to continue.."); Console.ReadKey(); } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); // Send input to our main process, if running if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1) { // If we're running more than 1 process, bail, and send input to the main process var client = new IpcClient(); client.Initialize(IpcPort); client.Send(JsonConvert.SerializeObject(new IpcMessage { Name = "ProcStartArgs", Payload = e.Args })); // Shutdown the process Shutdown(0); return; } StartupUri = new Uri("MainWindow.xaml", UriKind.Relative); }
private static void updater_UpdatesFound(object sender, EventArgs e) { var freyaUpdater = Updater.Instance; Console.ForegroundColor = ConsoleColor.Yellow; logger.WriteLine(string.Format("[H] Local --> Server Version: {0} --> {1}", freyaUpdater.Context.CurrentVersion, freyaUpdater.Context.UpdateInfo.AppVersion)); logger.WriteLine("[H] New Version Found:" + freyaUpdater.Context.UpdateInfo.AppVersion); Console.ResetColor(); // Stop and Uninstall Service StopService(); UninstallService(); // Uninstall Registry keys (Startup) try { RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (key != null) { key.DeleteValue("FreyaUI"); } RegistryKey key1 = Registry.LocalMachine.OpenSubKey("Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (key1 != null) { key1.DeleteValue("FreyaUI"); } logger.WriteLine("[H] Registry key deleted"); } catch (Exception) { } if (!FFunc.HasRight(FConstants.FeatureByte.Hide)) { // Deploy FreyaUI WatchDog int servicePort = (FFunc.GetRegKey("FreyaUIPort") == null) ? 10000 : (int)FFunc.GetRegKey("FreyaUIPort"); logger.WriteLine($"[H] Deploying Watchdog for FreyaUI... (UIPort={servicePort})"); IpcClient radioClient = new IpcClient(); radioClient.Initialize(servicePort); string result = radioClient.Send("{ \"Type\": \"CMD\", \"Data\": \"StartUpdateProcess\", \"Data2\": \"\",\"Loglevel\": 0}"); Thread.Sleep(1000); logger.WriteLine("[H] UI feedback: " + result); //if (radioClient.Send("{ \"Type\": \"CMD\", \"Data\": \"DeployWacthDog\", \"Data2\": \"\",\"Loglevel\": 0}") != "WatchDogDeployed") // Console.WriteLine(radioClient.Send("{ \"Type\": \"CMD\", \"Data\": \"DeployWacthDog\", \"Data2\": \"\",\"Loglevel\": 0}")); Thread.Sleep(1000); } else { logger.WriteLine("[H] Hide mode, no watchdog."); } KillProcess(); Console.ForegroundColor = ConsoleColor.DarkYellow; logger.WriteLine("[H] Starting update"); logger.WriteLine("[H] Check Service exist:" + ServiceExists(FConstants.ServiceName).ToString()); freyaUpdater.StartExternalUpdater(); logger.WriteLine("[H] Updater thread started in background. Terminate Heimdallr."); Console.ResetColor(); }
private bool getStatus() { return(getStatus(radioClient.Send(JsonConvert.SerializeObject(new FMsg { Type = "CMD", Data = "GetStatus" })))); }
private static void SendIpcMessage(PatcherIpcMessages.PatcherIpcEnvelope envelope) { _client.Send(Base64Encode(JsonConvert.SerializeObject(envelope, Formatting.None, JsonSettings))); }
public string SendCmd(string cmd) { return(client.Send(cmd)); }
private void SendOnClick(object?sender, EventArgs e) { _client.Send("Hola from Client"); }
private void Options_OK_Click(object sender, EventArgs ea) { Options_Cancel.Enabled = false; Options_OK.Enabled = false; /// DMS /// RegSetting.DMS_Enable = checkBox_DMSEnable.Checked; if (RegSetting.DMS_Enable && (textBox_DMS_UserID.Text.Length <= 0 || textBox_DMS_Password.Text.Length <= 0)) { MessageBox.Show("Need DMS UserID and Password to enable AutoDMS.\r\nPlease provide correct UserID and Password in AutoDMS page."); this.DialogResult = DialogResult.None; Options_Cancel.Enabled = true; Options_OK.Enabled = true; return; } RegSetting.DMS_TriggerAt = dateTimePicker_DMS_TriggerAt.Value; RegSetting.DMS_Setting.From = dateTimePicker_DMS_From.Value; RegSetting.DMS_Setting.To = dateTimePicker_DMS_To.Value; RegSetting.DMS_Setting.UserID = textBox_DMS_UserID.Text; RegSetting.DMS_Setting.setPassword(textBox_DMS_Password.Text); RegSetting.DMS_Setting.Items = (int)numericUpDown_DMS_Items.Value; RegSetting.DMS_Setting.Action = textBox_DMS_Action.Text; RegSetting.DMS_Setting.Target = textBox_DMS_Target.Text; RegSetting.DMS_Setting.Event = textBox_DMS_Event.Text; RegSetting.DMS_Setting.project = comboBox_DMS_Projects.SelectedValue?.ToString(); KeyValuePair <string, string> selected = (KeyValuePair <string, string>)comboBox_DMS_Projects.SelectedItem; RegSetting.DMS_Setting.projectname = selected.Value; /// Advanced /// RegSetting.LogLevel = (FConstants.FreyaLogLevel)comboBox_LogLevel.SelectedItem; RegSetting.SMTPLogWriterEnable = checkBox_SMTPLogWriterEnable.Checked; /// Mail /// if (textBox_Email.Text.Length > 0) { RegSetting.EMail = textBox_Email.Text; } if (textBox_Password.Text.Length > 0) { RegSetting.setPassword(textBox_Password.Text); } if (textBox_SMTPServer.Text.Length > 0) { RegSetting.SMTPServerIP = textBox_SMTPServer.Text; } if (textBox_WebService.Text.Length > 0) { RegSetting.WebServiceIP = textBox_WebService.Text; } if (textBox_IMAPServer.Text.Length > 0) { RegSetting.IMAPServerIP = textBox_IMAPServer.Text; } RegSetting.SMTPLogLevel = (string)comboBox_SMTPLogLevel.SelectedItem; /// Check IMAP account string IMAPAuthResult = string.Empty; if (sw_needIMAPAuthCheck && !(RegSetting.hasRight(FConstants.FeatureByte.Hide) || RegSetting.hasRight(FConstants.FeatureByte.Odin))) { new FormWait(() => { // Start IMAP authenticate using (var client = new ImapClient()) { try { client.ServerCertificateValidationCallback = (s, c, h, e) => true; client.Connect(RegSetting.IMAPServerIP, 993, SecureSocketOptions.SslOnConnect); // Bug of MailKit // https://stackoverflow.com/questions/39573233/mailkit-authenticate-to-imap-fails client.AuthenticationMechanisms.Remove("NTLM"); client.Authenticate(RegSetting.EMail, RegSetting.getPassword()); client.Disconnect(true); } catch (Exception ex) { IMAPAuthResult = ex.Message.ToString(); } } }).SetMessage("Validating IMAP account...").ShowDialog(); } if (IMAPAuthResult.Length > 0) { MessageBox.Show("Email or Password may be wrong, please check again.\r\n\r\n" + IMAPAuthResult); this.DialogResult = DialogResult.None; Options_Cancel.Enabled = true; Options_OK.Enabled = true; return; } else { string RegJSON = JsonConvert.SerializeObject(RegSetting); radioClient.Send(JsonConvert.SerializeObject(new FMsg { Type = "CMD", Data = "WriteRegistry", Data2 = RegJSON })); } }