public void QueryLiveInfo(Action <Networking.ServerInfo> onServerRulesReceived) { if (!SteamManager.IsInitialized) { return; } if (int.TryParse(QueryPort, out _)) { if (PingHQuery != null) { SteamManager.Instance.ServerList.CancelHQuery(PingHQuery.Value); PingHQuery = null; } MatchmakingPingResponse = new Facepunch.Steamworks.ISteamMatchmakingPingResponse( SteamManager.Instance.Client, (server) => { ServerName = server.Name; RespondedToSteamQuery = true; PlayerCount = server.Players; MaxPlayers = server.MaxPlayers; HasPassword = server.Passworded; PingChecked = true; Ping = server.Ping; LobbyID = 0; server.FetchRules(); server.OnReceivedRules += (bool received) => { SteamManager.OnReceivedRules(server, this, received); onServerRulesReceived?.Invoke(this); }; }, () => { RespondedToSteamQuery = false; }); PingHQuery = SteamManager.Instance.ServerList.HQueryPing(MatchmakingPingResponse, IPAddress.Parse(IP), int.Parse(QueryPort)); } else if (OwnerID != 0) { if (SteamFriend == null) { SteamFriend = SteamManager.Instance.Friends.Get(OwnerID); } if (LobbyID == 0) { SteamFriend.Refresh(); if (SteamFriend.IsPlayingThisGame && SteamFriend.ServerLobbyId != 0) { LobbyID = SteamFriend.ServerLobbyId; SteamManager.Instance.LobbyList.RequestLobbyData(LobbyID); } else { RespondedToSteamQuery = false; } } } }
public void OnInvitedToGame(Facepunch.Steamworks.SteamFriend friend, string connectCommand) { ToolBox.ParseConnectCommand(connectCommand.Split(' '), out ConnectName, out ConnectEndpoint, out ConnectLobby); DebugConsole.NewMessage(ConnectName + ", " + ConnectEndpoint, Color.Yellow); }
public void QueryLiveInfo(Action <Networking.ServerInfo> onServerRulesReceived) { if (!SteamManager.IsInitialized) { return; } if (int.TryParse(QueryPort, out _)) { if (PingHQuery != null) { SteamManager.Instance.ServerList.CancelHQuery(PingHQuery.Value); PingHQuery = null; } MatchmakingPingResponse = new Facepunch.Steamworks.ISteamMatchmakingPingResponse( SteamManager.Instance.Client, (server) => { ServerName = server.Name; RespondedToSteamQuery = true; PlayerCount = server.Players; MaxPlayers = server.MaxPlayers; HasPassword = server.Passworded; PingChecked = true; Ping = server.Ping; LobbyID = 0; server.FetchRules(); server.OnReceivedRules += (bool received) => { SteamManager.OnReceivedRules(server, this, received); onServerRulesReceived?.Invoke(this); }; }, () => { RespondedToSteamQuery = false; }); PingHQuery = SteamManager.Instance.ServerList.HQueryPing(MatchmakingPingResponse, IPAddress.Parse(IP), int.Parse(QueryPort)); } else if (OwnerID != 0) { if (SteamFriend == null) { SteamFriend = SteamManager.Instance.Friends.Get(OwnerID); } if (LobbyID == 0) { SteamFriend.Refresh(); if (SteamFriend.IsPlayingThisGame && SteamFriend.ServerLobbyId != 0) { LobbyID = SteamFriend.ServerLobbyId; SteamManager.Instance.LobbyList.SetManualLobbyDataCallback(LobbyID, (lobby) => { SteamManager.Instance.LobbyList.SetManualLobbyDataCallback(LobbyID, null); if (string.IsNullOrWhiteSpace(lobby.GetData("haspassword"))) { return; } bool.TryParse(lobby.GetData("haspassword"), out bool hasPassword); int.TryParse(lobby.GetData("playercount"), out int currPlayers); int.TryParse(lobby.GetData("maxplayernum"), out int maxPlayers); //UInt64.TryParse(lobby.GetData("connectsteamid"), out ulong connectSteamId); string ip = lobby.GetData("hostipaddress"); UInt64 ownerId = SteamManager.SteamIDStringToUInt64(lobby.GetData("lobbyowner")); if (OwnerID != ownerId) { return; } if (string.IsNullOrWhiteSpace(ip)) { ip = ""; } ServerName = lobby.Name; Port = ""; QueryPort = ""; IP = ip; PlayerCount = currPlayers; MaxPlayers = maxPlayers; HasPassword = hasPassword; RespondedToSteamQuery = true; LobbyID = lobby.LobbyID; OwnerID = ownerId; PingChecked = false; OwnerVerified = true; SteamManager.AssignLobbyDataToServerInfo(lobby, this); onServerRulesReceived?.Invoke(this); }); SteamManager.Instance.LobbyList.RequestLobbyData(LobbyID); } else { RespondedToSteamQuery = false; } } } }