public void AbrirServidor() { if (abrirServer) { abrirServer.interactable = false; } if (unirseManual) { unirseManual.interactable = false; } foreach (var bot in botonAutoJoin.Values) { bot.interactable = false; } panelDeConexion.SetActive(false); panelDeJuego.SetActive(true); NetworkManager.singleton.StartHost(); if (!string.IsNullOrEmpty(gameScene)) { NetworkManager.singleton.ServerChangeScene(gameScene); } var lobbiTalVez = SteamMatchmaking.CreateLobbyAsync().ContinueWith(resultado => { if (resultado.Result.HasValue) { var lobbi = resultado.Result.Value; lobbi.SetPublic(); } }); }
public async Task LobbyCreate(int delay = 100) { var lobbyr = await SteamMatchmaking.CreateLobbyAsync(32); if (!lobbyr.HasValue) { PrintError("Couldn't Create!"); return; } var lobby = lobbyr.Value; lobby.SetPublic(); lobby.SetData("gametype", "sausage"); lobby.SetData("dicks", "unlicked"); Print($"lobby: {lobby.Id}"); foreach (var entry in lobby.Data) { Print($" - {entry.Key} {entry.Value}"); } Print($"members: {lobby.MemberCount}/{lobby.MaxMembers}"); Print($"Owner: {lobby.Owner}"); Print($"Owner Is Local Player: {lobby.Owner.IsMe}"); lobby.SendChatString("Hello I Love Lobbies"); await Task.Delay(1000); }
public async Task <Lobby> CreateLobby(LobbyCreateParams createParams) { var result = await SteamMatchmaking.CreateLobbyAsync((int)createParams.Capacity); var steamLobby = result ?? throw new Exception("Failed to create the lobby"); if (createParams.Type == LobbyType.Public) { steamLobby.SetPublic(); } if (createParams.Metadata != null) { foreach (var kvp in createParams.Metadata) { if (kvp.Key == null || kvp.Value == null) { continue; } steamLobby.SetData(kvp.Key, kvp.Value.ToString()); } } var lobby = new SteamLobby(steamLobby, this, true); _connectedLobbies.Add(steamLobby.Id, lobby); return(lobby); }
/// <summary> /// Create steam lobby asynchronously /// Starts a new FacepunchP2PServer if lobby creation successful /// </summary> /// <returns></returns> private async Task CreateLobby() { Steamworks.Data.Lobby?lobby = await SteamMatchmaking.CreateLobbyAsync(MAXIMUM_SERVER_SLOTS); if (lobby.HasValue) { lobbyToJoin = (Steamworks.Data.Lobby)lobby; CreateFacepunchP2PServer(); } // TODO: Raise a dialog to inform of the failed lobby creation attempt }
public SocketManager CreateSession(string port) { var netAddress = NetAddress.AnyIp(ushort.Parse(port)); Server = SteamNetworkingSockets.CreateNormalSocket <MaydayServer>(netAddress); ((MaydayServer)Server).NetworkManager = this; SteamMatchmaking.OnLobbyCreated += (result, lobby) => OnLobbyCreated(result, lobby, port); SteamMatchmaking.CreateLobbyAsync(); return(Server); }
/// <summary> /// Creates a steam lobby /// </summary> /// <returns></returns> private async void CreateLobby() { Steamworks.Data.Lobby?lobbyCreated = await SteamMatchmaking.CreateLobbyAsync(MaxConnections); if (!lobbyCreated.HasValue) { Logging.BMSLog.LogWarning("Could not create lobby"); return; } Lobby = lobbyCreated.Value; // Now that we have the steam lobby, safe to set up the FacepunchP2PServer Host(true); }
private async Task CreateLobby() { Steamworks.Data.Lobby?lobbyCreated = await SteamMatchmaking.CreateLobbyAsync(64); if (!lobbyCreated.HasValue) { BMSLog.Log("Error creating lobby"); return; } BMSLog.Log("Created Lobby Async: lobby Id = " + lobbyCreated.Value.Id); var lobbyVal = lobbyCreated.Value; lobbyVal.SetPublic(); lobbyVal.SetData("FNR-FP", "blob"); this.lobby = lobbyVal; BMSLog.Log("Starting Host fuction"); ((FacepunchP2PServer)steamP2PServer).Host(); Connected(steamP2PServer); //Load 02aLobbyHost scene levelManager.LoadLevel("02aLobbyHost"); }
void Start() { defaultYs = new float[] { transform.GetChild(0).localPosition.y, transform.GetChild(1).localPosition.y }; lobbyButtonsPool = new ObjectPool(LobbyButtonPrefab, LobbyListGroup.transform, 20); lobbyInfoTextPool = new ObjectPool(LobbyInfoTextPrefab, LobbyInfoGroup.transform, 10); RefreshButton.onClick.AddListener(OnRefreshButtonClick); CreateLobbyButton.onClick.AddListener(OnCreateLobbyClick); JoinLobbyButton.onClick.AddListener(OnJoinLobbyClick); async void OnCreateLobbyClick() { var lobbyTask = await SteamMatchmaking.CreateLobbyAsync(5); if (lobbyTask.HasValue) { var lobby = lobbyTask.Value; if (lobby.SetPublic() && lobby.SetJoinable(true)) { Debug.Log("Succesfully created lobby"); lobby.Owner = new Friend(SteamClient.SteamId); lobby.SetDefaultData(); // CreatedLobby?.Invoke(); await JoinLobby(lobby); } } } async Task JoinLobby(Lobby?lobby) { var joinTask = await lobby.Value.Join(); if (joinTask == RoomEnter.Success) { Debug.Log("succesfully joined lobby"); lobbyInfoTextPool.DeactivateAll(); lobbyButtonsPool.DeactivateAll(); selectedLobby = null; GameData.Instance.CurrentLobby = lobby.Value; JoinedLobby?.Invoke(); } else { Debug.LogError($"error when joining lobby: {joinTask}"); } } async void OnJoinLobbyClick() { if (selectedLobby.HasValue) { await JoinLobby(selectedLobby); } } void OnRefreshButtonClick() { lobbyButtonsPool.DeactivateAll(); UpdateLobbyList(); } }
public void CreateSteamLobby() { SteamMatchmaking.CreateLobbyAsync(maxConnections); ClientCreateLobbyAttempted?.Invoke(); }
public async void FindMatch() { findMatchBtn.onClick.RemoveListener(FindMatch); findMatchBtn.onClick.AddListener(CancelMatch); findOrCancelMatchText.text = "CANCEL"; //exitGameBtn.enabled = false; //findMatchBtn.enabled = false; //allowedSteamIDs.Clear(); lobbyList = await SteamMatchmaking.LobbyList.RequestAsync(); SteamMatchmaking.OnLobbyGameCreated += SteamMatchmaking_OnLobbyGameCreated; SteamMatchmaking.OnLobbyEntered += SteamMatchmaking_OnLobbyEntered; SteamMatchmaking.OnLobbyCreated += SteamMatchmaking_OnLobbyCreated; SteamMatchmaking.OnLobbyMemberJoined += SteamMatchmaking_OnLobbyMemberJoined; Debug.Log("Lobbies Count: " + lobbyList.Length); foreach (Lobby lobby in lobbyList) { //Debug.Log("LobbyMemberCount: " + lobby.MemberCount); //Debug.Log("LobbyMaxMembers: " + lobby.MaxMembers); if (lobby.MemberCount < lobby.MaxMembers) { //Debug.Log("LobbyMemberCount < MaxMembers"); if (steamDevAppID == 480) { //Debug.Log("AppID is 480, using dev code."); if (lobby.GetData("lobbyName").Contains("opus")) { Debug.Log("Joining a lobby (480 app id)."); ourLobbyId = lobby.Id; await lobby.Join(); } } else { //Debug.Log("Joining a lobby, not 480. Using production code."); ourLobbyId = lobby.Id; await lobby.Join(); } } } if (!isInLobby) { //Debug.Log("Couldn't find a lobby, creating our own."); var lobbyr = await SteamMatchmaking.CreateLobbyAsync(maxLobbyMembers); if (!lobbyr.HasValue) { //Debug.Log("Couldn't create lobby."); return; } var lobby = lobbyr.Value; lobby.SetPublic(); lobby.SetJoinable(true); lobby.SetData("lobbyName", "opus"); } }