Beispiel #1
0
        void Start()
        {
            IsServer = NetworkOptions.StartServer;
            IsClient = NetworkOptions.StartClient;

            if (IsServer)
            {
                _serverManager = new ServerGameManager();
                _serverRunner  = new ServerThreadRunner();

                var thread = new System.Threading.Thread(() => {
                    _serverRunner.Run(_serverManager, 50, 1000, new System.Threading.CancellationTokenSource());
                });
                thread.Start();
                System.Threading.Thread.Sleep(50);
                if (!_serverManager.Initialized)
                {
                    Debug.Log("not Initialized");
                    EventManager.Subscribe <OnServerInitializationFinished>(this, OnServerInitializationFinished);
                    return;
                }
            }
            System.Threading.Thread.Sleep(10);
            TryStartClient();
            StartCoroutine(RareUpdate());
        }
Beispiel #2
0
        void Start()
        {
            PersistentDataPath = Application.persistentDataPath;
            IsServer           = NetworkOptions.StartServer;
            IsClient           = NetworkOptions.StartClient;
            var inst = Instance;

            if (!inst)
            {
                Debug.LogError("GameManager.Start: GameManager singleton instance is null!");
            }
            if (IsServer)
            {
                _serverManager = new ServerGameManager();
                _serverRunner  = new ServerThreadRunner();
                System.Threading.Thread.Sleep(10);                 //just in case
                var thread = new System.Threading.Thread(() => {
                    _serverRunner.Run(_serverManager, 50, 1000, new System.Threading.CancellationTokenSource());
                });
                thread.Start();
                System.Threading.Thread.Sleep(500);
                if (!_serverManager.Initialized)
                {
                    Debug.Log("not Initialized");
                    EventManager.Subscribe <OnServerInitializationFinished>(this, OnServerInitializationFinished);
                    return;
                }
            }
            System.Threading.Thread.Sleep(10);
            TryStartClient();
        }