public void CreateNewRoom() { createNewRoomView.Hide(); Msf.Events.Invoke(EventKeys.showLoadingInfo, "Starting room... Please wait!"); // Spawn options for spawner controller var spawnOptions = new DictionaryOptions(); spawnOptions.Add(MsfDictKeys.maxPlayers, createNewRoomView.MaxConnections); spawnOptions.Add(MsfDictKeys.roomName, createNewRoomView.RoomName); // Custom options that will be given to room directly var customSpawnOptions = new DictionaryOptions(); customSpawnOptions.Add(Msf.Args.Names.StartClientConnection, string.Empty); Msf.Client.Spawners.RequestSpawn(spawnOptions, customSpawnOptions, createNewRoomView.RegionName, (controller, error) => { if (controller == null) { Msf.Events.Invoke(EventKeys.hideLoadingInfo); Msf.Events.Invoke(EventKeys.showOkDialogBox, new OkDialogBoxViewEventMessage(error, null)); return; } Msf.Events.Invoke(EventKeys.showLoadingInfo, "Room started. Finalizing... Please wait!"); MsfTimer.WaitWhile(() => { return(controller.Status != SpawnStatus.Finalized); }, (isSuccess) => { Msf.Events.Invoke(EventKeys.hideLoadingInfo); if (!isSuccess) { Msf.Client.Spawners.AbortSpawn(controller.SpawnTaskId); logger.Error("Failed spawn new room. Time is up!"); Msf.Events.Invoke(EventKeys.showOkDialogBox, new OkDialogBoxViewEventMessage("Failed spawn new room. Time is up!", null)); return; } gamesListView.Show(); mainView.Hide(); logger.Info("You have successfully spawned new room"); }, 60f); }); }