private void AddNewHostEntry() { string defaultHost = MainApp.GetInstance().GetConfig().GetApplicationConfig()._defaultHost; HostStatus newHost = MainApp.GetInstance().GetHostsController().AddHost(defaultHost); AddHostEntry(newHost); }
private void ProcessResponseMesssage(HostStatus host, string command, string message) { SimpleJSON.JSONNode jsonResponse = SimpleJSON.JSON.Parse(message); string output = string.Empty; string resultValue = jsonResponse["result"]; if (resultValue != null && resultValue == "1") { output = host._host + ": sent succcess"; string restultData = jsonResponse["data"]; if (restultData != null) { output += restultData; } } else { output = host._host + ": sent failed"; } _mainWindow.GetConsole().WriteOutput(output); }
public HostStatus AddHost(string host) { HostStatus newHost = new HostStatus(); newHost._host = host; _hosts.Add(newHost); return(newHost); }
public WidgetHostTargetEntry(HostStatus host) { this.Build(); _host = host; _inputHostTarget.Text = host._host; RefreshVisuals(); _inputHostTarget.TextInserted += OnTextInsertedEvent; }
public void TryConnectHost(HostStatus host) { HostConnectionThread hostConnectionThread = new HostConnectionThread(host); hostConnectionThread.OnConnectionDoneEvent += RegisterConnectionMessage; Thread connectionThread = new Thread(hostConnectionThread.ExecuteThread); connectionThread.Start(); }
private void AddHostEntry(HostStatus host) { WidgetHostTargetEntry hostTargetWidget = new WidgetHostTargetEntry(host); hostTargetWidget.OnEntryDeletedEvent += OnEntryDeleted; hostTargetWidget.OnEntryUpdateConnectionEvent += OnEntryUpdateConnectionEvent; hostTargetWidget.Show(); _hostTargets.Add(hostTargetWidget); _hostTargetsCanvas.Add(hostTargetWidget); RefreshVisuals(); }
private WidgetHostTargetEntry GetWidgetHostEntry(HostStatus host) { foreach (WidgetHostTargetEntry widgetHost in _hostTargets) { if (widgetHost.GetHost() == host) { return(widgetHost); } } Debug.Assert(false, "Widget host entry not found!"); return(null); }
private void ExecuteSingleCommandOnHost(HostStatus host, string targetCommand, string command, string arguments) { try { ApplicationConfig appConfig = MainApp.GetInstance().GetConfig().GetApplicationConfig(); string message = ""; string urlCommand = string.Empty; urlCommand += "http://"; urlCommand += host._host; urlCommand += ":" + appConfig._port; urlCommand += "/" + appConfig._service; urlCommand += "/" + targetCommand; urlCommand += "?command=" + command; if (arguments.Length > 0) { urlCommand += "&" + arguments; } WebRequest wrGETURL; wrGETURL = WebRequest.Create(urlCommand); System.IO.Stream objStream; objStream = wrGETURL.GetResponse().GetResponseStream(); System.IO.StreamReader objReader = new System.IO.StreamReader(objStream); string sLine = ""; while (sLine != null) { sLine = objReader.ReadLine(); if (sLine != null) { message += sLine; } } ProcessResponseMesssage(host, command, message); } catch (System.Exception ex) { _mainWindow.GetConsole().WriteOutput(host._host + ": sent failed, " + ex.Message); host._connectionStatus = HostStatus.EStatus.Disconnected; _hostsController.TryConnectHost(host); } }
public void RemoveHost(HostStatus host) { _hosts.Remove(host); }
public void RegisterConnectionMessage(HostStatus host, string resultMessage) { _mutexPendingMessages.WaitOne(); _pendingMessages.Add(resultMessage); _mutexPendingMessages.ReleaseMutex(); }
public HostConnectionThread(HostStatus host) { _host = host; }