Como sacar variable de Public void?

(1/1)

PaPeRrO:
Hola, estoy haciendo un programa que conecta a un servidor telnet y le envia unos comandos, para ello utilizo la DLL dotnettelnet. necesito sacar un dato de una funcion. en concreto e.Data en OnDataAvailable ¿como tengo que hacerlo? Gracias :P

aqui esta dotnettelnet.
http://sourceforge.net/project/showfiles.php?group_id=55312&package_id=50227&release_id=162640

este es el codigo:
Código
 
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using De.Mud.Telnet;
using System.IO;
 
 
namespace Net.Graphite.Telnet
{
   /// <summary>
   /// A simple console testbed for the Telnet application.
   /// </summary>
   public class TestClient
   {
       [STAThread]
       static void Main(string[] args)
 
       {
 
           string Direccion;
           string puerto;
           Direccion = "aqui va la ip del servidor telnet";
           puerto = "23";
 
 
 
           TestRun tr = new TestRun(Direccion, Int32.Parse(puerto));
 
           try
           {
 
                   tr.InteractiveSession();// edit the method for specific cmds
 
           }
           catch (Exception e)
           {
               Console.WriteLine("An exception has occurred: " +
                   e.Message + "\n\n" + e.StackTrace + "\n");
           }
 
       }
   }
 
   public class TestRun
   {
       private TelnetWrapper t;
       private bool done = false;
       private StreamReader sr;
       public string Datos;
       public TestRun(string host, int port)
       {
           t = new TelnetWrapper();
 
           t.Disconnected += new DisconnectedEventHandler(this.OnDisconnect);
           t.DataAvailable += new DataAvailableEventHandler(this.OnDataAvailable);
 
           t.TerminalType = "NETWORK-VIRTUAL-TERMINAL";
           t.Hostname = host;
           t.Port = port;
           Console.WriteLine("Connecting ...");
           t.Connect();
 
       }
 
       public void ScriptedSession()
       {
           Console.WriteLine("Not implemented.");
       }
 
       public void InteractiveSession()
       {
           //int i;
           //char ch;
 
           try
           {
               t.Receive();
               string envio;                                            
               envio = "admin\r\n";
 
               string envio2;
 
               string llegada;
               envio2 = "sys iface\r\n";
               //while (!done)
                   t.Send(envio + envio2);
 
                   //Console.ReadLine();
                   //t.Send(envio2);
 
 
                   //t.Send(Console.ReadLine() + t.CRLF);
 
 
 
           }
           catch
           {
               t.Disconnect();
               throw;
           }
       }
 
       private void OnDisconnect(object sender, EventArgs e)
       {
           done = true;
           Console.WriteLine("\nDisconnected.");
 
       }
 
 
       public void OnDataAvailable(object sender, DataAvailableEventArgs e)
       {
 
 
 
           //Console.Write(e.Data);
 
           this.Datos += e.Data
       }
 
 
 
   }
}
 
 
 

Navegación

[0] Índice de Mensajes