Ejemplo n.º 1
0
 /// <summary>
 /// This will start server in test mode
 /// </summary>
 protected virtual void StartServerInEditor()
 {
     if (startServerAsHost)
     {
         MirrorNetworkManager.StopHost();
         MstTimer.WaitForSeconds(0.2f, () => MirrorNetworkManager.StartHost());
     }
     else
     {
         MirrorNetworkManager.StopServer();
         MstTimer.WaitForSeconds(0.2f, () => MirrorNetworkManager.StartServer());
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Before we register our room we need to register spawned process if required
        /// </summary>
        protected void RegisterSpawnedProcess()
        {
            // Let's register this process
            Mst.Server.Spawners.RegisterSpawnedProcess(Mst.Args.SpawnTaskId, Mst.Args.SpawnTaskUniqueCode, (taskController, error) =>
            {
                if (taskController == null)
                {
                    logger.Error($"Room server process cannot be registered. The reason is: {error}");
                    return;
                }

                // If max players was given from spawner task
                if (taskController.Options.Has(MstDictKeys.roomName))
                {
                    roomOptions.Name = taskController.Options.AsString(MstDictKeys.roomName);
                }

                // If room is public or not
                if (taskController.Options.Has(MstDictKeys.roomIsPublic))
                {
                    roomOptions.IsPublic = taskController.Options.AsBool(MstDictKeys.roomIsPublic);
                }

                // If max players param was given from spawner task
                if (taskController.Options.Has(MstDictKeys.roomMaxPlayers))
                {
                    roomOptions.MaxConnections = taskController.Options.AsInt(MstDictKeys.roomMaxPlayers);
                }

                // If password was given from spawner task
                if (taskController.Options.Has(MstDictKeys.roomPassword))
                {
                    roomOptions.Password = taskController.Options.AsString(MstDictKeys.roomPassword);
                }

                // Set port of the Mirror server
                SetPort(roomOptions.RoomPort);

                // Finalize spawn task before we start mirror server
                taskController.FinalizeTask(new MstProperties(), () =>
                {
                    // Start Mirror server
                    MirrorNetworkManager.StartServer();
                });
            });
        }