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"); });
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) }; }
internal WebsiteTransmitter(EnergizeClient client, OctoClient octoClient) : base(client, octoClient) { this.ServiceManager = client.ServiceManager; this.DiscordClient = client.DiscordClient; this.DiscordRestClient = client.DiscordRestClient; this.Prefix = client.Prefix; this.MessageSender = client.MessageSender; }
public DebuggingWindow(OctoClient client) { this.InitializeComponent(); this.Client = client; this.Processes = new List <string>(client.AvailableProcesses.Select(proc => proc.Name)); this.PrintInitDetails(); this.Client.Log += log => this.PrintLine(log.Content); this.Client.ProcessEnded += this.OnProcessTerminated; this.Client.ProcessRegistered += this.OnProcessRegistered; this.Client.Connected += this.OnClientConnected; this.Client.Registered += this.OnClientRegistered; this.Client.Disconnected += this.OnClientDisconnected; if (File.Exists("Resources/syntax_highlight.xshd")) { using (XmlTextReader reader = new XmlTextReader(File.OpenRead("Resources/syntax_highlight.xshd"))) this.Editor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance); } this.ChangeConnectivityState("Registered", Brushes.Green); this.ChangeProcessesCount(this.Client.AvailableProcessesCount); this.PingTimer = new Timer(_ => { try { Ping ping = new Ping(); PingReply reply = ping.Send(this.Client.ServerAddress); if (reply.Status == IPStatus.Success) { ExecuteOnGraphicalThread(() => this.ChangeDelay(reply.RoundtripTime)); } else { ExecuteOnGraphicalThread(() => this.ChangeDelay(-1)); } } catch { ExecuteOnGraphicalThread(() => this.ChangeDelay(-1)); } }); this.PingTimer.Change(1000, 1000); this.Editor.Text = @"/* Use the 'Client' variable to interact with * the debugger octovisor client. * * Use the 'Print' method to output objects and * values in the debugger console. */ // Your code here..."; }
static void Main(string[] args) { ClientConfiguration configuration = new ClientConfiguration(); configuration.mode = ClientMode.Standalone; configuration.port = 8001; OctoClient octoClient = new OctoClient(configuration); octoClient.connect(); Console.Read(); }
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); }
static async Task SpamRemoteProcessAsync(OctoClient client, string procName) { var last = DateTime.Now; if (client.TryGetProcess(procName, out RemoteProcess proc)) { for (int i = 0; i < 10; i++) { string result = await proc.TransmitObjectAsync <TestClass, string>("meme", new TestClass()); Console.WriteLine($"{client.ProcessName}: {result}"); } Console.WriteLine($"Took {(DateTime.Now - last).TotalMilliseconds}ms"); } else { Console.WriteLine($"Didnt find {procName}"); } }
public async Task <T> TransmitToEnergizeAsync <T>(string identifier) { T data = default; try { OctoClient client = this.Client; if (!client.IsConnected) { await client.ConnectAsync(); } if (client.TryGetProcess("Energize", out RemoteProcess proc)) { data = await proc.TransmitAsync <T>(identifier); } return(data == default ? Activator.CreateInstance <T>() : data); } catch (Exception ex) { Console.WriteLine(ex); return(data == default ? Activator.CreateInstance <T>() : default);
public ExecutionContext(DebuggingWindow win, OctoClient client) { this.Window = win; this.Client = client; }
internal WatchdogTransmitter(EnergizeClient client, OctoClient octoClient) : base(client, octoClient) { this.ServiceManager = client.ServiceManager; this.MessageSender = client.MessageSender; this.DiscordClient = client.DiscordClient; }
internal BaseTransmitter(EnergizeClient client, OctoClient octoClient) { this.Client = octoClient; this.Logger = client.Logger; }