Exemplo n.º 1
0
 public static void InitializeServer(AsynchronousServer.NewMessageReceived[] additionalCallbacks = null)
 {
     if (isInitialized)
     {
         return;
     }
     server = new AsynchronousServer(JobEnvVariables.GetMyDestinationPortForChildren());
     AddDelegateForMessagesDispatcher();
     AddDelegateForNewChildGreeting();
     AddDelegatesForProtocolMessages();
     if (additionalCallbacks != null)
     {
         Array.ForEach(additionalCallbacks, callback => server.NewMessageReceivedEvent += callback);
     }
     server.Start();
     isInitialized = true;
 }
Exemplo n.º 2
0
 public static void Initialize()
 {
     if (isInitialized)
     {
         return;
     }
     client = new AsynchronousClient();
     client.NewMessageReceivedEvent += (classInstance, server) => {
         if (classInstance is ISystemMessage systemMessage)
         {
             systemMessage.Dispatch(server);
         }
     };
     HelloFromParent.OnReceive += (socket, helloFromParent) => {
         C.log.Info("Sending hello from child");
         client.Send(new HelloFromChild()
         {
             MyJobId = JobEnvVariables.GetMyJobId()
         });
     };
     client.Connect(JobEnvVariables.GetParentSubmitterIp(), JobEnvVariables.GetParentSubmitterDestinationPort());
     isInitialized = true;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Checks if currently executing application is a root process.
 /// </summary>
 /// <returns>true if currently executing app is root process; false otherwise</returns>
 public static bool AmIRootProcess()
 {
     return(JobEnvVariables.GetNestLevel() == 0);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Acquires IP address of parent submitter.
 /// </summary>
 /// <returns>IPAddress of the parent</returns>
 public static IPAddress GetMyParentIpAddress()
 {
     return(JobEnvVariables.GetParentSubmitterIp());
 }
Exemplo n.º 5
0
 /// <summary>
 /// Checks for nest level of currently executing application.
 /// </summary>
 /// <returns>nest level of currently executing application (0 for root process, 1 for first level one etc.)</returns>
 public static int GetMyNestLevel()
 {
     return(JobEnvVariables.GetNestLevel());
 }