4/30/12

TCExecutor v0.0.1 released

TCExecutor - Telnet Command Executor C# open source project is released in version 0.0.1

Thanks to TCExecutor you can add communication/configuration layer to your application in just four steps:

  1. Create TCExecutor object
  2. Define commands
  3. Hook up your code to commands events (TCExecutor is multithread/multiconection application remeber that your code must be threadsafe)
  4. Start TCExecutor listener.
Commands style:
>command1 subcommand1 ... subcommandN param1=X1 ... paramN=XN ARGV1...ARGVN



Features:
  • Adds network communication layer to your application
  • Supports multiple connections. For each connection separate session is established.
  • Commands can be defined at your application startup.
  • Each command has separate event to which you can connect to.
  • Each command has a short and long help string which helps end user to navigate through available options.
Next releases features:
  • Enable SSH connections to the TCExecutor.
  • Add simple user autentication. Login password.
Project in action


Project can be found here: https://bitbucket.org/chesti/tcexecutor/
You can clone code from git: git clone https://bitbucket.org/chesti/tcexecutor.git
Code example:

using TelentCommandExecutor;

class ProgramObject
{
   private TCExecutor executorSRV;

   public ProgramObject()
   {
      //create an executor
      executorSRV = new TCExecutor();
   
      //hook up some commands
      CmdExecutor e;
      e = executorSRV.AddCommand("set name");
      e.ExecutorEvent += new CmdExecutor.ExecutorHandler(Execute_SetName);
      e.HelpString = "set name n=name";
      e.ShortHelpString = "Dispalys your name";
      
      //listen to the any end point on port 9999
      System.Net.IPEndPoint endPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Any, 9999);
      //start executor
      executorSRV.StartServer(endPoint);

      Console.ReadKey();

      //stop executor and disconnect all users.
      executorSRV.StopServer();
   }
   
   //handle command event
   string Execute_SetName(Cmd command)
   {
      if (command.CmdParams.ContainsKey("n"))
      {
          return String.Format("Your name is: {0}", command.CmdParams["n"]);
      }
      else
      {
         return "Use n= parameter";
      }
   }
}