/// <summary> /// This will start server in test mode /// </summary> protected virtual void StartServerInEditor() { if (startServerAsHost) { RoomNetworkManager.StartHost(); } else { RoomNetworkManager.StartServer(); } }
/// <summary> /// This will start server in test mode /// </summary> protected virtual void StartServerInEditor() { if (startServerAsHost) { RoomNetworkManager.StopHost(); MstTimer.WaitForSeconds(0.2f, () => RoomNetworkManager.StartHost()); } else { RoomNetworkManager.StopServer(); MstTimer.WaitForSeconds(0.2f, () => RoomNetworkManager.StartServer()); } }
/// <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.ROOM_NAME)) { roomOptions.Name = taskController.Options.AsString(MstDictKeys.ROOM_NAME); } // If room is public or not if (taskController.Options.Has(MstDictKeys.ROOM_IS_PUBLIC)) { roomOptions.IsPublic = taskController.Options.AsBool(MstDictKeys.ROOM_IS_PUBLIC); } // If max players param was given from spawner task if (taskController.Options.Has(MstDictKeys.ROOM_MAX_PLAYERS)) { roomOptions.MaxConnections = taskController.Options.AsInt(MstDictKeys.ROOM_MAX_PLAYERS); } // If password was given from spawner task if (taskController.Options.Has(MstDictKeys.ROOM_PASSWORD)) { roomOptions.Password = taskController.Options.AsString(MstDictKeys.ROOM_PASSWORD); } // Set port of the Mirror server SetPort(roomOptions.RoomPort); // Finalize spawn task before we start mirror server taskController.FinalizeTask(new MstProperties(), () => { // Start Mirror server RoomNetworkManager.StartServer(); }); }); }