Пример #1
0
        private void ShutdownNetwork()
        {
            LANDiscoveryHost.Shutdown();

            Running = false;

            lock (Locker)
            {
                WorkerThread?.Abort();
                WorkerThread = null;
            }

            Server.Shutdown("BYE!");
        }
Пример #2
0
        public void Shutdown()
        {
            ActiveScenario.Shutdown();
            ActiveScenario = null;

            ShutdownNetwork();

            if (ServiceInfo != null)
            {
                ServiceList.RemoveLocalService();
            }

            LANDiscoveryHost.Shutdown();

            ServiceInfo = null;
        }
Пример #3
0
        private void Listen(int port)
        {
            SetupMessages();

            NetPeerConfiguration config = new NetPeerConfiguration("LL_ShipHost_" + ShipMessage.ProtocolVersion.ToString());

            config.Port = port;
            config.AcceptIncomingConnections = true;
            config.AutoFlushSendQueue        = true;
            Server = new NetServer(config);

            Running = true;
            Server.Start();

            WorkerThread = new Thread(new ThreadStart(ProcessNetwork));
            WorkerThread.Start();

            LANDiscoveryHost.Startup();
        }
Пример #4
0
        protected void Register()
        {
            ServiceInfo = new HostedService();

            ServiceInfo.IDKey = HostedService.GenerateKey();

            ServiceInfo.Name       = StartupInfo.Name;
            ServiceInfo.Port       = StartupInfo.Port;
            ServiceInfo.WANAddress = StartupInfo.ServerWANHost;
            ServiceInfo.LANAddress = StartupInfo.ServerLANAddress;
            ServiceInfo.Secured    = StartupInfo.Password != string.Empty;

            ServiceInfo.Properties.Add(new Tuple <string, string>("FTL", StartupInfo.FTL.ToString()));
            ServiceInfo.Properties.Add(new Tuple <string, string>("SensorRange", StartupInfo.SensorRange.ToString()));
            ServiceInfo.Properties.Add(new Tuple <string, string>("TacticalRadarMSD", StartupInfo.TacticalRadarMSD.ToString()));
            ServiceInfo.Properties.Add(new Tuple <string, string>("LongRangeRadarMSD", StartupInfo.LongRangeRadarMSD.ToString()));
            ServiceInfo.Properties.Add(new Tuple <string, string>("Scans", StartupInfo.Scans.ToString()));
            ServiceInfo.Properties.Add(new Tuple <string, string>("UseWeaponFrequencies", StartupInfo.UseWeaponFrequencies.ToString()));
            ServiceInfo.Properties.Add(new Tuple <string, string>("UseSystemDamage", StartupInfo.UseSystemDamage.ToString()));

            if (StartupInfo.SelectedScenario != null)
            {
                ServiceInfo.Properties.Add(new Tuple <string, string>("ScenarioName", StartupInfo.SelectedScenario.Name));
                ServiceInfo.Properties.Add(new Tuple <string, string>("ScenarioDescription", StartupInfo.SelectedScenario.Description));
                ServiceInfo.Properties.Add(new Tuple <string, string>("ScenarioAuthor", StartupInfo.SelectedScenario.Author));
                ServiceInfo.Properties.Add(new Tuple <string, string>("ScenarioIconImage", StartupInfo.SelectedScenario.IconImage));
                ServiceInfo.Properties.Add(new Tuple <string, string>("ScenarioType", StartupInfo.SelectedScenario.Type));
                if (StartupInfo.SelectedVariation != null)
                {
                    ServiceInfo.Properties.Add(new Tuple <string, string>("ScenarioVariationName", StartupInfo.SelectedVariation.DisplayName));
                    ServiceInfo.Properties.Add(new Tuple <string, string>("ScenarioVariationDescription", StartupInfo.SelectedVariation.Description));
                }
            }

            else
            {
                ServiceInfo.Properties.Add(new Tuple <string, string>("ScenarioName", "NONE"));
            }

            ServiceList.RegisterLocalService(ServiceInfo, StartupInfo.Public);

            LANDiscoveryHost.Startup();
        }