Exemplo n.º 1
0
        private void getNewPort(IPAddress managerAddress, int registrationPort)
        {
            TCPClient registrationConnection = new TCPClient(managerAddress, registrationPort);

            SharedLogger.Debug(workerName, "Registration Service", $"Registration sent to {managerAddress}:{registrationPort}.");
            registrationConnection.SendObject <string>("REGISTER");
            //while (!registrationConnection.MessageIsAvailable())
            //{
            //    Thread.Sleep(500);
            //}
            string[] registrationInfo = registrationConnection.ReceiveObject <string>().Split('|');
            workerName = registrationInfo[1];
            managerMessageProcessor.UpdateRunnerName(workerName);
            SharedLogger.Msg(workerName, "Registration Service", $"Registered to manager server at {managerAddress.ToString()} with port assignment {registrationInfo[0]}.");
            assignedPort = Convert.ToInt32(registrationInfo[0]);
        }