Brunet.Applications.Examples.HelloWorldNodeDataHandler.Main C# (CSharp) Method

Main() public static method

public static Main ( string args ) : int
args string
return int
    public static int Main(string [] args) {
      // Create a new RuntimeParameters to parse the args
      RuntimeParameters parameters = new RuntimeParameters(
          "HelloWorldNodeDataHandler",
          "HelloWorld using IDataHandler/ISender paradigm");

      // Parse the args, if we don't get 0 back, there was an error
      if(parameters.Parse(args) != 0) {
        // Print the error and help
        Console.WriteLine(parameters.ErrorMessage);
        parameters.ShowHelp();
        // exit after error
        return -1;
      } else if(parameters.Help) {
        // Caller asked for help, let's print it
        parameters.ShowHelp();
        // exit after printing help
        return 0;
      }

      // Instantiate a new inherited node of your choice
      HelloWorldNodeDataHandler hwn =
        new HelloWorldNodeDataHandler(parameters.NodeConfig);
      // And run it... this hijacks the current thread, we'll return once the node disconnects
      hwn.Run();

      Console.WriteLine("Exiting...");

      return 0;
    }
  }