static void Main(string[] args) { //new connection var con = new TelnetClient(FromConfig.Server, 23, 30); try { if (!con.Login(FromConfig.Username, FromConfig.Password)) { throw new Exception("Failed to connect."); } Console.WriteLine("In"); con.SendAndWait("cd /", "$"); con.SendAndWait("ls -ltr", "$"); Console.WriteLine(con.SessionLog); con.Disconnect(); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine(con.SessionLog); Console.WriteLine(ex.Message); } }
// This method transmits a series of instructions to NASA's Horizons system, requesting the name, mass and radius values of a specific object // as well as the specific position and velocity vectors at a specific point in time. // This request is done in relation to the Sun, meaning that the Sun is at 0,0,0 in this co-ordinate system. private void HandleMessageReceived(object sender, string message) { Console.WriteLine(message); output.Add(message); if (message.Contains("System news updated")) { telnetClient.Send(Planet.ToString()); Thread.Sleep(50); telnetClient.Send("E"); Thread.Sleep(50); telnetClient.Send("v"); Thread.Sleep(50); telnetClient.Send("@sun"); Thread.Sleep(50); telnetClient.Send("eclip"); Thread.Sleep(50); telnetClient.Send("2018AD-Nov-11 00:00"); Thread.Sleep(50); telnetClient.Send("2018AD-Nov-11 00:01"); Thread.Sleep(50); telnetClient.Send("1d"); Thread.Sleep(50); telnetClient.Send("y"); } else if (message.Contains("$$EOE")) { telnetClient.Disconnect(); } }
private void DisconnectFromServer() { try { _server.Disconnect(); } catch {} _serverData = new ServerData(); _serverData.TelnetState = TelnetState.disconnected; if (this.InvokeRequired) { this.BeginInvoke((MethodInvoker) delegate() { this.buttonConnect.Text = "Connect to Server";; }); } else { this.buttonConnect.Text = "Connect to Server"; } return; }