Exemplo n.º 1
0
        /// <summary>
        /// Start the server
        /// </summary>
        /// <returns></returns>
        public bool Start()
        {
            if (Logging)
            {
                Logger.Write("REGION", "Method [Start]");
            }

            if (!ListenThread.IsAlive && !Running)
            {
                if (Logging)
                {
                    Logger.Write("SUCCESS", "Starting server");
                }

                Running = true;

                ListenThread.Start();
                ManagementThread.Start();
                return(true);
            }

            if (Logging)
            {
                Logger.Write("FAILED", "Starting server");
            }

            return(false);
        }
Exemplo n.º 2
0
        public void TestAddRTControllerAndSoftRemoveInstance()
        {
            Assert.AreEqual(true, CRController.AddRadioTelescopeController(RTController0));
            Assert.AreEqual(true, CRController.AddRadioTelescopeController(RTController1));
            Assert.AreEqual(true, CRController.AddRadioTelescopeController(RTController2));

            foreach (RadioTelescopeControllerManagementThread ManagementThread in CRController.ControlRoom.RTControllerManagementThreads)
            {
                ManagementThread.Start();
            }

            Assert.AreEqual(true, CRController.RemoveRadioTelescopeController(RTController0, true));
            Assert.AreEqual(true, CRController.RemoveRadioTelescopeController(RTController1, true));
            Assert.AreEqual(true, CRController.RemoveRadioTelescopeController(RTController2, true));
        }
Exemplo n.º 3
0
        public void TestAddRTControllerAndHardRemoveIndex()
        {
            Assert.AreEqual(true, CRController.AddRadioTelescopeController(RTController0));
            Assert.AreEqual(true, CRController.AddRadioTelescopeController(RTController1));
            Assert.AreEqual(true, CRController.AddRadioTelescopeController(RTController2));

            foreach (RadioTelescopeControllerManagementThread ManagementThread in CRController.ControlRoom.RTControllerManagementThreads)
            {
                ManagementThread.Start();
            }


            Assert.AreEqual(true, CRController.RemoveRadioTelescopeControllerAt(0, false));
            Assert.AreEqual(true, CRController.RemoveRadioTelescopeControllerAt(0, false));
            Assert.AreEqual(true, CRController.RemoveRadioTelescopeControllerAt(0, false));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Stop the server
        /// </summary>
        public void Stop()
        {
            if (Logging)
            {
                Logger.Write("REGION", "Method [Stop]");
            }

            if (Logging)
            {
                Logger.Write("INFO", "Stopping server");
            }

            Running = false;

            lock (ClientsList)
                lock (ClientsDict) {
                    for (int e = ClientsList.Count - 1; e >= 0; e--)
                    {
                        TCPServerClient client = ClientsList[e];

                        RemoveClient(client, TCPDisconnectType.Disconnect, e);
                    }
                }

            try {
                Socket.Shutdown(SocketShutdown.Both);
                Socket.Close();
            } catch (Exception er) {
            }

            ManagementThread.Join();
            ListenThread.Join();

            ListenThread     = new Thread(() => Listen());
            ManagementThread = new Thread(Management);

            Socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
            Socket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, false);
            Socket.Bind(new IPEndPoint(Address, Port));

            if (Logging)
            {
                Logger.Write("INFO", "Stopped server");
            }
        }