static async Task MainAsync() { OctoConfig config = new OctoConfig { Token = "cool", Address = "localhost", Port = 6558, ProcessName = "Process2", }; OctoClient client = new OctoClient(config); client.Log += log => Console.WriteLine($"{log.Severity} >> {log.Content}"); await client.ConnectAsync(); Console.WriteLine("Ready"); foreach (RemoteProcess proc in client.AvailableProcesses) { Console.WriteLine(proc.Name); } client.OnTransmission <TestClass, string>("meme", (proc, data) => { Console.WriteLine($"{proc.Name}: {(data is null ? "null" : data.ToString())}"); return("hello world"); });
private void OnConfigFileClick(object sender, RoutedEventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog { Filter = "YAML Config files (.yaml)|*.yaml", FileName = "config", DefaultExt = ".yaml" }; bool?result = fileDialog.ShowDialog(); if (result.HasValue && result.Value) { try { OctoConfig config = OctoConfig.FromFile(fileDialog.FileName); this.SaveConfig(config); this.TBAddress.Text = config.Address; this.TBPort.Text = config.Port.ToString(); this.TBProcessName.Text = config.ProcessName; this.TBTimeout.Text = config.Timeout.ToString(); this.TBToken.Password = config.Token; this.TBBufferSize.Text = config.BufferSize.ToString(); this.TBCompressionTreshold.Text = config.CompressionThreshold.ToString(); } catch (Exception ex) { ExceptionPopup.ShowException(ex); } } }
private void SaveConfig(OctoConfig config) { Serializer serializer = new Serializer(); string yaml = serializer.Serialize(config); File.WriteAllText("last_config.yaml", yaml); }
public TransmissionService(EnergizeClient client) { OctovisorConfig config = Config.Instance.Octovisor; OctoConfig octoConfig = new OctoConfig { Address = config.Address, Port = config.Port, ProcessName = config.ProcessName, Token = config.Token, }; this.Logger = client.Logger; this.OctoClient = new OctoClient(octoConfig); this.OctoClient.Log += log => { if (log.Severity == LogSeverity.Info) { this.Logger.Nice("Octo", ConsoleColor.Magenta, log.Content); } }; this.Transmitters = new List <BaseTransmitter> { new WebsiteTransmitter(client, this.OctoClient), new WatchdogTransmitter(client, this.OctoClient) }; }
private async void OnConnect(object sender, RoutedEventArgs e) { Button btn = (Button)sender; btn.IsHitTestVisible = false; btn.Background = Brushes.Gray; DebuggingWindow win = null; try { OctoConfig config = new OctoConfig { Address = this.TBAddress.Text, Port = int.Parse(this.TBPort.Text), Token = this.TBToken.Password, ProcessName = this.TBProcessName.Text, BufferSize = int.Parse(this.TBBufferSize.Text), CompressionThreshold = int.Parse(this.TBCompressionTreshold.Text), Timeout = int.Parse(this.TBTimeout.Text), }; this.SaveConfig(config); OctoClient client = new OctoClient(config); await client.ConnectAsync(); this.Visibility = Visibility.Collapsed; win = new DebuggingWindow(client); win.ShowDialog(); // In case debugging window is closed with Windows if (client.IsConnected) { await client.DisconnectAsync(); } this.Visibility = Visibility.Visible; } catch (Exception ex) { ExceptionPopup.ShowException(ex); win?.Close(); this.Visibility = Visibility.Visible; } btn.IsHitTestVisible = true; BrushConverter converter = new BrushConverter(); btn.Background = (Brush)converter.ConvertFromString("#191919"); }
internal NetworkWatcher(OctoConfig config, Logger logger) : base("Network", logger) { this.PingInterval = Config.Instance.Network.PingInterval; this.RemoteProcessName = Config.Instance.Network.RemoteProcessName; this.Client = new OctoClient(config); this.Client.Log += this.OnLog; this.Client.Disconnected += this.OnClientDisconnectedAsync; this.Client.ProcessRegistered += this.OnProcessRegistered; this.PingTimer = new Timer(this.OnTimerAsync); this.InfoUponReconnect = false; this.Reconnecting = false; this.Disconnecting = false; this.NetworkFailures = 0; this.LastDisconnectedTime = DateTime.Now; }
static async Task <OctoClient> CreateClientAsync(string procName) { OctoConfig config = new OctoConfig { Token = "cool", Address = "localhost", Port = 6558, ProcessName = procName, }; OctoClient client = new OctoClient(config); client.Log += log => Console.WriteLine($"{log.Severity} >> {log.Content}"); await client.ConnectAsync(); return(client); }
private void LoadLastConfig() { if (!File.Exists("last_config.yaml")) { return; } try { OctoConfig config = OctoConfig.FromFile("last_config.yaml"); this.TBAddress.Text = config.Address; this.TBPort.Text = config.Port.ToString(); this.TBProcessName.Text = config.ProcessName; this.TBTimeout.Text = config.Timeout.ToString(); this.TBToken.Password = config.Token; this.TBBufferSize.Text = config.BufferSize.ToString(); this.TBCompressionTreshold.Text = config.CompressionThreshold.ToString(); } catch { File.Delete("last_config.yaml"); } }
internal NetworkWatcher CreateNetworkWatcher(OctoConfig config) => new NetworkWatcher(config, this.Logger);