/// <summary> /// Add a steam Lobby to the list of visible lobbies /// </summary> /// <param name="lobby">The Steamworks Lobby to add to the list</param> private void AddServer(Steamworks.Data.Lobby lobby) { var hostName = lobby.Id.Value.ToString(); for (int i = 0; i < serverList.Count; ++i) { var server = serverList[i]; if (server.Hostname == hostName) { // Already have that server listed nothing else to do return; } } var serverListItemData = new FacepunchServerListItemData { ListItem = GameObject.Instantiate <FacepunchServerListEntry>(serverListEntryTemplate, servers.content), Hostname = hostName, }; serverListItemData.ListItem.gameObject.SetActive(true); serverListItemData.lobby = lobby; UpdateItem(serverListItemData); serverListItemData.NextUpdate = Time.time + 5.0f + UnityEngine.Random.Range(0.0f, 1.0f); serverList.Add(serverListItemData); SetListItemSelected(serverListItemData, false); RepositionItems(); }
void OnLobbyInvite(Friend member, Steamworks.Data.Lobby steamLobby) { /*SteamLobby lobby = new SteamLobby(steamLobby, this); * lobby._lobby = steamLobby; * lobby.Members.Refresh();*/ Debug.Log(member.Name + " invited you"); }
private void OnLobbyDataChanged(Steamworks.Data.Lobby lobby) { BMSLog.Log("Lobby data changed, new data:"); foreach (KeyValuePair <string, string> data in lobby.Data) { BMSLog.Log(data.Key + "; " + data.Value); } }
void OnLobbyMemberLeave(Steamworks.Data.Lobby steamLobby, Friend member) { SteamLobby lobby; if (!_connectedLobbies.TryGetValue(steamLobby.Id, out lobby)) { Debug.LogWarning($"[Steam] Unexpected lobby member join event for lobby: {steamLobby.Id}"); return; } lobby.Members.Remove(new AccountHandle(member.Id)); }
void OnLobbyDataChanged(Steamworks.Data.Lobby steamLobby) { SteamLobby lobby; if (!_connectedLobbies.TryGetValue(steamLobby.Id, out lobby)) { Debug.LogWarning($"[Steam] Unexpected lobby update event for lobby: {steamLobby.Id}"); return; } lobby.DispatchUpdate(); }
/// <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 }
/// <summary> /// Spawns the listing UI prefab and initializes it's values /// </summary> /// <param name="server"></param> public static void CreateLobbyListing(Steamworks.Data.Lobby lobby) { if (MainMenu.singleton.serverListingParent != null) { ServerListingUI s = Instantiate(MainMenu.singleton.serverListingPrefab, MainMenu.singleton.serverListingParent).GetComponent <ServerListingUI>(); s.isDedicated = false; s.lobby = lobby; s.InitLobby(); } }
private async Task JoinLobby(Steamworks.Data.Lobby lobbyToJoin) { RoomEnter roomEnter = await lobbyToJoin.Join(); if (roomEnter != RoomEnter.Success) { BMSLog.Log("Error connecting to lobby returned: " + roomEnter.ToString()); return; } this.lobby = lobbyToJoin; BMSLog.Log("Connected to lobby, owner.Id = " + lobbyToJoin.Owner.Id.Value); ConnectToHost(lobbyToJoin.Owner.Id, null); }
/// <summary> /// Connect to the selected steam lobby /// On successful connection, starts a new FacepunchP2PClient for connection to the lobby owner's FacepunchP2PServer /// </summary> private async Task ConnectToLobby() { RoomEnter roomEnter = await lobbyToJoin.Join(); if (roomEnter != RoomEnter.Success) { BMSLog.Log("Error connecting to lobby returned: " + roomEnter.ToString()); return; } this.lobby = lobbyToJoin; ConnectToServer(lobbyToJoin.Owner.Id); }
private Steamworks.Data.Lobby GetLobby() { if (lobby.Id.Value > 0) { return(lobby); } else { lobby = networkController.GetLobby(); if (lobby.Id.Value > 0) { return(lobby); } else { BMSLog.LogWarning("Could not find this lobby"); return(default);
private void OnLobbyCreated(Steamworks.Result result, Steamworks.Data.Lobby lobby) { Debug.Log("Lobby creation result: " + result); if (result == Steamworks.Result.OK) { myLobby = lobby; lobby.SetData("id", Steamworks.SteamClient.SteamId.ToString()); lobby.SetData("name", lobbyName); lobby.SetData("pingLocation", Steamworks.SteamNetworkingUtils.LocalPingLocation.ToString()); // Set ourselves as a moderator ServerActions.Mod(Steamworks.SteamClient.SteamId); lobby.SetPublic(); Debug.Log("Starting network host"); // Shut down host before starting if (Mirror.NetworkClient.active) { Mirror.NetworkManager.singleton.StopClient(); } if (Mirror.NetworkServer.active) { Mirror.NetworkManager.singleton.StopServer(); } // Start host NetworkManagerCallbacks.singleton.StartHost(); Mirror.NetworkManager.singleton.ServerChangeScene("gameplay"); } else { Debug.Log("Unable to create lobby."); } }
void OnLobbyMemberDataChanged(Steamworks.Data.Lobby steamLobby, Friend friend) { SteamLobby lobby; LobbyMember member; if (!_connectedLobbies.TryGetValue(steamLobby.Id, out lobby)) { Debug.LogWarning($"[Steam] Unexpected lobby member update event for lobby: {steamLobby.Id}"); return; } var handle = new AccountHandle(friend.Id); if (!lobby.Members.TryGetValue(handle, out member)) { Debug.LogWarning($"[Steam] Unexpected lobby member update event for lobby: {steamLobby.Id}"); return; } member.DispatchUpdate(); }
public void CancelGame(bool loadMenu = true) { BMSLog.Log("Cancelling game start and reloading main menu"); UnsubscribeP2PClientEvents(); UnsubscribeP2PServerEvents(); lobby.Leave(); lobby = default; if (haveNetworkManager) { BMSLog.Log("Calling networkManager.Disconnect()"); networkManager.Disconnect(); haveNetworkManager = false; } if (loadMenu) { LevelManager.LoadMainMenu(); } }
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"); }
private void OnLobbyEntered(Steamworks.Data.Lobby lobby) { // Return if we are the host if (Mirror.NetworkServer.active) { return; } myLobby = lobby; Debug.Log("We joined a lobby."); Debug.Log("Connecting mirror client to the id associated with the lobby."); Mirror.NetworkManager.singleton.networkAddress = lobby.GetData("id"); if (!Mirror.NetworkManager.singleton.isNetworkActive) { Mirror.NetworkManager.singleton.StartClient(); } }
void OnLobbyMemberRemoved(Steamworks.Data.Lobby steamLobby, Friend member, Friend authorizer) => OnLobbyMemberLeave(steamLobby, member);
private void OnLobbyMemberJoined(Steamworks.Data.Lobby lobby, Friend friend) { BMSLog.Log("Player joined lobby: " + friend.Name); }
private void OnLobbyMemberLeave(Steamworks.Data.Lobby lobby, Friend friend) { BMSLog.Log("Player left lobby: " + friend.Name); }
void OnChatMessage(Steamworks.Data.Lobby lobby, Friend friend, string msg) { Debug.Log("[Steam] " + friend.Name + ": " + msg); }
public void ConnectToLobby(Steamworks.Data.Lobby lobbyToJoin) { JoinLobbyAsync(lobbyToJoin); }
private async void JoinLobbyAsync(Steamworks.Data.Lobby lobbyToJoin) { await JoinLobby(lobbyToJoin); }