public override void Execute(ITerminalCommandChannel terminalCommandChannel, System.Action <string> prompt) { if (terminalCommandChannel is NetworkPeerManager) { Handled = true; var networkPeerManager = terminalCommandChannel as NetworkPeerManager; foreach (var peer in networkPeerManager.Peers.GetAll()) { var stringBuilder = new StringBuilder(); stringBuilder.Append(peer.Identity == null ? "unset:" : peer.Identity.ToString()); foreach (var ep in peer.NetworkConnection.NetworkPoints) { if (peer.NetworkConnection.AvailableNetworkPoint == null) { stringBuilder.Append(string.Format("{0}({1})", ep.ToString(), "inactive")); } else { stringBuilder.Append(string.Format("{0}({1})", ep.ToString(), peer.NetworkConnection.AvailableNetworkPoint.Equals(ep) ? "active" : "inactive")); } } prompt.Invoke(stringBuilder.ToString()); } Result = TerminalCommandResult.Done(); } }
public override void Execute(ITerminalCommandChannel terminalCommandChannel, Action <string> prompt) { if (terminalCommandChannel is ApplicationManager) { Handled = true; var applicationManager = terminalCommandChannel as ApplicationManager; if (TerminalCommandLine.Keys.Length == 0) { try { applicationManager.Start(); Result = TerminalCommandResult.Done(); } catch (Exception e) { Result = TerminalCommandResult.Error(e.Message); } } else { Result = TerminalCommandResult.InvalidArguments(); } } }
public override void Execute(ITerminalCommandChannel terminalCommandChannel, Action <string> prompt) { if (terminalCommandChannel is NetworkPeerManager) { Handled = true; var networkPeerManager = terminalCommandChannel as NetworkPeerManager; var networkPeerType = TerminalCommandLine["type"]; if (networkPeerType == null || !(networkPeerType.Equals("normal", StringComparison.OrdinalIgnoreCase) || networkPeerType.Equals("tracker", StringComparison.OrdinalIgnoreCase))) { Result = TerminalCommandResult.InvalidArguments(); return; } var ipEndPointString = TerminalCommandLine["ep"]; if (ipEndPointString == null) { Result = TerminalCommandResult.InvalidArguments(); return; } var ipEndPoint = IPEndPointHelper.ConvertFromString(ipEndPointString); if (ipEndPoint == null) { Result = TerminalCommandResult.InvalidArguments(); return; } var networkPoint = new NetworkPointBase(ipEndPoint); foreach (var peer in networkPeerManager.Peers.GetAll()) { if (peer.NetworkConnection.NetworkPoints.Exists(networkPoint)) { return; } } if (networkPeerType.Equals("normal", StringComparison.OrdinalIgnoreCase)) { networkPeerManager.Peers.Add(new NormalNetworkPeerBase(null, new INetworkPoint[] { networkPoint })); } else if (networkPeerType.Equals("tracker", StringComparison.OrdinalIgnoreCase)) { networkPeerManager.Peers.Add(new TrackerNetworkPeerBase(null, new INetworkPoint[] { networkPoint })); } Result = TerminalCommandResult.Done(); } }