浏览代码

Revert "fix : Updated Lobby Package to Official Wire support"

This reverts commit aa480455f7524fab46259c99c259777a10127a02.
/main
UnityJacob 1年前
当前提交
9536d5a9
共有 6 个文件被更改,包括 283 次插入315 次删除
  1. 88
      Assets/Scripts/GameLobby/Game/GameManager.cs
  2. 20
      Assets/Scripts/GameLobby/Game/LocalLobby.cs
  3. 31
      Assets/Scripts/GameLobby/Lobby/LobbyConverters.cs
  4. 450
      Assets/Scripts/GameLobby/Lobby/LobbyManager.cs
  5. 2
      Packages/manifest.json
  6. 7
      Packages/packages-lock.json

88
Assets/Scripts/GameLobby/Game/GameManager.cs


public GameState LocalGameState { get; private set; }
public LobbyManager LobbyManager { get; private set; }
[SerializeField] SetupInGame m_setupInGame;
[SerializeField] Countdown m_countdown;
[SerializeField]
SetupInGame m_setupInGame;
[SerializeField]
Countdown m_countdown;
[SerializeField] List<vivox.VivoxUserHandler> m_vivoxUserHandlers;
[SerializeField]
List<vivox.VivoxUserHandler> m_vivoxUserHandlers;
LobbyColor m_lobbyColorFilter;

{
try
{
var lobby = await LobbyManager.JoinLobbyAsync(
lobbyID,
lobbyCode,
var lobby = await LobbyManager.JoinLobbyAsync(lobbyID, lobbyCode,
//Force the UI to update for Clients
m_LocalUser.IsHost.ForceSet(false);
await JoinLobby();
}
catch (Exception exception)

{
LobbyList.QueryState.Value = LobbyQueryState.Fetching;
var qr = await LobbyManager.RetrieveLobbyListAsync(m_lobbyColorFilter);
if (qr == null)
{
return;
}
SetCurrentLobbies(LobbyConverters.QueryToLocalList(qr));
}

public void SetLocalUserStatus(PlayerStatus status)
{
m_LocalUser.UserStatus.Value = status;
SendLocalUserData();
}

SendLocalLobbyData();
}
bool updatingLobby;
async void SendLocalLobbyData()
{
await LobbyManager.UpdateLobbyDataAsync(LobbyConverters.LocalToRemoteLobbyData(m_LocalLobby));

state = GameState.Lobby;
ClientQuitGame();
}
SetGameState(state);
}

public void FinishedCountDown()
{
SetLocalUserStatus(PlayerStatus.InGame);
m_LocalLobby.LocalLobbyState.Value = LobbyState.CountDown;
SendLocalLobbyData();
m_LocalUser.UserStatus.Value = PlayerStatus.InGame;
m_LocalLobby.LocalLobbyState.Value = LobbyState.InGame;
m_setupInGame.StartNetworkedGame(m_LocalLobby, m_LocalUser);
}

}
}
void ClientQuitGame()
public void ClientQuitGame()
{
EndGame();
m_setupInGame?.OnGameEnd();

LocalGameState == GameState.Lobby;
LocalGameState = state;
if (isLeavingLobby)
{
#pragma warning disable 4014
LobbyManager.LeaveLobbyAsync();
#pragma warning restore 4014
}
Debug.Log($"Switching Game State to : {LocalGameState}");
if (isLeavingLobby)
LeaveLobby();
onGameStateChanged.Invoke(LocalGameState);
}

async Task CreateLobby()
{
m_LocalLobby.onUserReadyChange += OnPlayersReady;
await JoinLobby();
}
async Task JoinLobby()
{
m_LocalLobby.LocalLobbyState.onChanged += OnLobbyStateChanged;
m_LocalLobby.onUserReadyChange = OnPlayersReady;
await LobbyManager.BindLocalLobbyToRemote(m_LocalLobby.LobbyID.Value, m_LocalLobby);
LobbyManager.OnKicked += LeaveLobby;
SetLobbyView();
StartVivoxJoin();
await BindLobby();
}
catch (Exception exception)
{

void LeaveLobby()
async Task JoinLobby()
{
//Trigger UI Even when same value
m_LocalUser.IsHost.ForceSet(false);
await BindLobby();
}
async Task BindLobby()
{
await LobbyManager.BindLocalLobbyToRemote(m_LocalLobby.LobbyID.Value, m_LocalLobby);
m_LocalLobby.LocalLobbyState.onChanged += OnLobbyStateChanged;
SetLobbyView();
StartVivoxJoin();
}
public void LeaveLobby()
#pragma warning disable 4014
LobbyManager.LeaveLobbyAsync();
#pragma warning restore 4014
ResetLocalLobby();
m_LocalLobby.LocalLobbyState.onChanged -= OnLobbyStateChanged;
m_LocalLobby.ResetLobby();
m_LocalLobby.RelayServer.Value = null;
LobbyManager.OnKicked -= LeaveLobby;
}
void StartVivoxLogin()

void SetLobbyView()
{
Debug.Log($"Setting Lobby user state {GameState.Lobby}");
}
void ResetLocalLobby()
{
m_LocalLobby.ResetLobby();
m_LocalLobby.RelayServer = null;
}
#region Teardown

void OnDestroy()
{
ForceLeaveAttempt();
LobbyManager.Dispose();
}
void ForceLeaveAttempt()

20
Assets/Scripts/GameLobby/Game/LocalLobby.cs


public CallbackValue<long> LastUpdated = new CallbackValue<long>();
public int PlayerCount => m_LocalPlayers.Count;
ServerAddress m_RelayServer;
public List<LocalPlayer> LocalPlayers => m_LocalPlayers;
LocalLobbyColor.Value = LobbyColor.None;
LocalLobbyColor.Value = LobbyRelaySample.LobbyColor.None;
onUserJoined = null;
onUserLeft = null;
HostID.onChanged += SetHost;
}
public LocalPlayer GetLocalPlayer(int index)

m_LocalPlayers.Insert(index, user);
user.UserStatus.onChanged += OnUserChangedStatus;
onUserJoined?.Invoke(user);
Debug.Log($"Added User: {user.DisplayName.Value} - {user.ID.Value} to slot {index + 1}/{PlayerCount}");
var userRemoved = m_LocalPlayers[playerIndex];
userRemoved.UserStatus.onChanged -= OnUserChangedStatus;
m_LocalPlayers[playerIndex].UserStatus.onChanged -= OnUserChangedStatus;
Debug.Log(
$"Removed User: {userRemoved.DisplayName.Value} - {userRemoved.ID.Value} from slot {playerIndex}/{MaxPlayerCount.Value - 1}");
}
void SetHost(string hostID)
{
foreach (var player in m_LocalPlayers)
player.IsHost.Value = player.ID.Value == hostID;
}
void OnUserChangedStatus(PlayerStatus status)

31
Assets/Scripts/GameLobby/Lobby/LobbyConverters.cs


/// </summary>
public static class LobbyConverters
{
public const string key_RelayCode = nameof(LocalLobby.RelayCode);
public const string key_LobbyState = nameof(LocalLobby.LocalLobbyState);
public const string key_LobbyColor = nameof(LocalLobby.LocalLobbyColor);
public const string key_LastEdit = nameof(LocalLobby.LastUpdated);
const string key_RelayCode = nameof(LocalLobby.RelayCode);
const string key_LobbyState = nameof(LocalLobby.LocalLobbyState);
const string key_LobbyColor = nameof(LocalLobby.LocalLobbyColor);
const string key_LastEdit = nameof(LocalLobby.LastUpdated);
public const string key_Displayname = nameof(LocalPlayer.DisplayName);
public const string key_Userstatus = nameof(LocalPlayer.UserStatus);
public const string key_Emote = nameof(LocalPlayer.Emote);
const string key_Displayname = nameof(LocalPlayer.DisplayName);
const string key_Userstatus = nameof(LocalPlayer.UserStatus);
const string key_Emote = nameof(LocalPlayer.Emote);
public static Dictionary<string, string> LocalToRemoteLobbyData(LocalLobby lobby)
{

localPlayer.Emote.Value = emote;
localPlayer.UserStatus.Value = userStatus;
}
}
/// <summary>

{
List<LocalLobby> returnList = new List<LocalLobby>();
if (response == null)
return returnList;
List<LocalLobby> retLst = new List<LocalLobby>();
returnList.Add(RemoteToNewLocal(lobby));
return returnList;
retLst.Add(RemoteToNewLocal(lobby));
return retLst;
LocalLobby localLobby = new LocalLobby();
RemoteToLocal(lobby, localLobby);
return localLobby;
LocalLobby data = new LocalLobby();
RemoteToLocal(lobby, data);
return data;
}
}
}

450
Assets/Scripts/GameLobby/Lobby/LobbyManager.cs


using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LobbyRelaySample.lobby;
using Unity.Services.Authentication;
using Unity.Services.Lobbies;
using Unity.Services.Lobbies.Models;

/// </summary>
///
/// Manages one Lobby at a time, Only entry points to a lobby with ID is via JoinAsync, CreateAsync, and QuickJoinAsync
public class LobbyManager
public class LobbyManager : IDisposable
const string key_RelayCode = nameof(LocalLobby.RelayCode);
const string key_LobbyState = nameof(LocalLobby.LocalLobbyState);
const string key_LobbyColor = nameof(LocalLobby.LocalLobbyColor);
const string key_Displayname = nameof(LocalPlayer.DisplayName);
const string key_Userstatus = nameof(LocalPlayer.UserStatus);
const string key_Emote = nameof(LocalPlayer.Emote);
public event Action OnKicked;
public Lobby CurrentLobby => m_CurrentLobby;
LocalLobby m_CurrentLocalLobby;
LobbyEventCallbacks m_LobbyEventCallbacks = new LobbyEventCallbacks();
const int
k_maxLobbiesToShow = 16; // If more are necessary, consider retrieving paginated results or using filters.

//We dont want to queue a quickjoin
if (m_QuickJoinCooldown.IsCoolingDown)
{
Debug.LogWarning("Quick Join Lobby hit the rate limit.");
UnityEngine.Debug.LogWarning("Quick Join Lobby hit the rate limit.");
return null;
}

return await LobbyService.Instance.QueryLobbiesAsync(queryOptions);
}
public async Task<Lobby> GetLobbyAsync(string lobbyId = null)
public async Task BindLocalLobbyToRemote(string lobbyID, LocalLobby localLobby)
{
m_LobbyEventCallbacks.LobbyChanged += async changes =>
{
if (changes.LobbyDeleted)
{
await LeaveLobbyAsync();
return;
}
//Lobby Fields
if (changes.Name.Changed)
localLobby.LobbyName.Value = changes.Name.Value;
if (changes.HostId.Changed)
localLobby.HostID.Value = changes.HostId.Value;
if (changes.IsPrivate.Changed)
localLobby.Private.Value = changes.IsPrivate.Value;
if (changes.IsLocked.Changed)
localLobby.Locked.Value = changes.IsLocked.Value;
if (changes.AvailableSlots.Changed)
localLobby.AvailableSlots.Value = changes.AvailableSlots.Value;
if (changes.MaxPlayers.Changed)
localLobby.MaxPlayerCount.Value = changes.MaxPlayers.Value;
if (changes.LastUpdated.Changed)
localLobby.LastUpdated.Value = changes.LastUpdated.Value.ToFileTimeUtc();
//Custom Lobby Fields
if (changes.Data.Changed)
LobbyChanged();
if (changes.PlayerJoined.Changed)
PlayersJoined();
if (changes.PlayerLeft.Changed)
PlayersLeft();
if (changes.PlayerData.Changed)
PlayerDataChanged();
void LobbyChanged()
{
foreach (var change in changes.Data.Value)
{
var changedValue = change.Value;
var changedKey = change.Key;
if (changedValue.Removed)
{
RemoveCustomLobbyData(changedKey);
}
if (changedValue.Changed)
{
ParseCustomLobbyData(changedKey, changedValue.Value);
}
}
void RemoveCustomLobbyData(string changedKey)
{
if (changedKey == key_RelayCode)
localLobby.RelayCode.Value = "";
}
void ParseCustomLobbyData(string changedKey, DataObject playerDataObject)
{
if (changedKey == key_RelayCode)
localLobby.RelayCode.Value = playerDataObject.Value;
if (changedKey == key_LobbyState)
localLobby.LocalLobbyState.Value = (LobbyState)int.Parse(playerDataObject.Value);
if (changedKey == key_LobbyColor)
localLobby.LocalLobbyColor.Value = (LobbyColor)int.Parse(playerDataObject.Value);
}
}
void PlayersJoined()
{
foreach (var playerChanges in changes.PlayerJoined.Value)
{
Player joinedPlayer = playerChanges.Player;
var id = joinedPlayer.Id;
var index = playerChanges.PlayerIndex;
var isHost = localLobby.HostID.Value == id;
var newPlayer = new LocalPlayer(id, index, isHost);
foreach (var dataEntry in joinedPlayer.Data)
{
var dataObject = dataEntry.Value;
ParseCustomPlayerData(newPlayer, dataEntry.Key, dataObject.Value);
}
localLobby.AddPlayer(index, newPlayer);
}
}
void PlayersLeft()
{
foreach (var leftPlayerIndex in changes.PlayerLeft.Value)
{
localLobby.RemovePlayer(leftPlayerIndex);
}
}
void PlayerDataChanged()
{
foreach (var lobbyPlayerChanges in changes.PlayerData.Value)
{
var playerIndex = lobbyPlayerChanges.Key;
var localPlayer = localLobby.GetLocalPlayer(playerIndex);
if (localPlayer == null)
continue;
var playerChanges = lobbyPlayerChanges.Value;
if (playerChanges.ConnectionInfoChanged.Changed)
{
var connectionInfo = playerChanges.ConnectionInfoChanged.Value;
Debug.Log(
$"ConnectionInfo for player {playerIndex} changed to {connectionInfo}");
}
if (playerChanges.LastUpdatedChanged.Changed) { }
//There are changes on the Player
if (playerChanges.ChangedData.Changed)
{
foreach (var playerChange in playerChanges.ChangedData.Value)
{
var changedValue = playerChange.Value;
//There are changes on some of the changes in the player list of changes
if (changedValue.Changed)
{
if (changedValue.Removed)
{
Debug.LogWarning("This Sample does not remove Player Values currently.");
continue;
}
var playerDataObject = changedValue.Value;
ParseCustomPlayerData(localPlayer, playerChange.Key, playerDataObject.Value);
}
}
}
}
}
};
m_LobbyEventCallbacks.LobbyEventConnectionStateChanged += lobbyEventConnectionState =>
{
Debug.Log($"Lobby ConnectionState Changed to {lobbyEventConnectionState}");
};
m_LobbyEventCallbacks.KickedFromLobby += () =>
{
Debug.Log("Left Lobby");
Dispose();
};
await LobbyService.Instance.SubscribeToLobbyEventsAsync(lobbyID, m_LobbyEventCallbacks);
}
void ParseCustomPlayerData(LocalPlayer player, string dataKey, string playerDataValue)
if (m_GetLobbyCooldown.TaskQueued)
return null;
await m_GetLobbyCooldown.QueueUntilCooldown();
if (dataKey == key_Emote)
player.Emote.Value = (EmoteType)int.Parse(playerDataValue);
else if (dataKey == key_Userstatus)
player.UserStatus.Value = (PlayerStatus)int.Parse(playerDataValue);
else if (dataKey == key_Displayname)
player.DisplayName.Value = playerDataValue;
}
public async Task<Lobby> GetLobbyAsync(string lobbyId = null)
{
await m_GetLobbyCooldown.QueueUntilCooldown();
return await LobbyService.Instance.GetLobbyAsync(lobbyId);
return m_CurrentLobby = await LobbyService.Instance.GetLobbyAsync(lobbyId);
if (m_LeaveLobbyOrRemovePlayer.IsCoolingDown)
return;
await LobbyService.Instance.RemovePlayerAsync(m_CurrentLobby.Id, AuthenticationService.Instance.PlayerId);
Debug.Log("Left Lobby!");
string playerId = AuthenticationService.Instance.PlayerId;
await LobbyService.Instance.RemovePlayerAsync(m_CurrentLobby.Id, playerId);
Dispose();
string playerId = AuthenticationService.Instance.PlayerId;
if (!InLobby())
return;
string playerId = AuthenticationService.Instance.PlayerId;
PlayerDataObject dataObj = new PlayerDataObject(
visibility: PlayerDataObject.VisibilityOptions.Member,
PlayerDataObject dataObj = new PlayerDataObject(visibility: PlayerDataObject.VisibilityOptions.Member,
if (dataCurr.ContainsKey(dataNew.Key))
dataCurr[dataNew.Key] = dataObj;
else

return;
await m_UpdatePlayerCooldown.QueueUntilCooldown();
if (!InLobby())
return;
UpdatePlayerOptions updateOptions = new UpdatePlayerOptions
{
Data = dataCurr,

Debug.Log($"SENDING : {dataCurr[LobbyConverters.key_Displayname].Value}'s Data" +
$" TO : \n {m_CurrentLocalLobby}");
await LobbyService.Instance.UpdatePlayerAsync(m_CurrentLobby.Id, playerId, updateOptions);
m_CurrentLobby = await LobbyService.Instance.UpdatePlayerAsync(m_CurrentLobby.Id, playerId, updateOptions);
}
public async Task UpdatePlayerRelayInfoAsync(string lobbyID, string allocationId, string connectionInfo)

AllocationId = allocationId,
ConnectionInfo = connectionInfo
};
await LobbyService.Instance.UpdatePlayerAsync(lobbyID, playerId, updateOptions);
m_CurrentLobby = await LobbyService.Instance.UpdatePlayerAsync(lobbyID, playerId, updateOptions);
if (!InLobby())
return;
Dictionary<string, DataObject> dataCurr = m_CurrentLobby.Data ?? new Dictionary<string, DataObject>();
var shouldLock = false;

dataCurr.Add(dataNew.Key, dataObj);
//Special Use: Get the state of the Local lobby so we can lock it from appearing in queries if it's not in the "Lobby" LocalLobbyState
if (dataNew.Key == LobbyConverters.key_LobbyState)
if (dataNew.Key == "LocalLobbyState")
{
Enum.TryParse(dataNew.Value, out LobbyState lobbyState);
shouldLock = lobbyState != LobbyState.Lobby;

return;
await m_UpdateLobbyCooldown.QueueUntilCooldown();
if (!InLobby())
return;
Debug.Log($"Updating Data in {m_CurrentLocalLobby}");
await LobbyService.Instance.UpdateLobbyAsync(m_CurrentLobby.Id, updateOptions);
m_CurrentLobby = await LobbyService.Instance.UpdateLobbyAsync(m_CurrentLobby.Id, updateOptions);
}
public async Task DeleteLobbyAsync()

await LobbyService.Instance.DeleteLobbyAsync(m_CurrentLobby.Id);
}
#region LobbyBindings
public async Task BindLocalLobbyToRemote(string lobbyID, LocalLobby localLobby)
public void Dispose()
m_CurrentLocalLobby = localLobby;
m_CurrentLobby = null;
m_LobbyEventCallbacks.LobbyChanged += ProcessLobbyChanges;
m_LobbyEventCallbacks.LobbyEventConnectionStateChanged += OnStateChanged;
m_LobbyEventCallbacks.KickedFromLobby += OnKickedFromLobby;
await LobbyService.Instance.SubscribeToLobbyEventsAsync(lobbyID, m_LobbyEventCallbacks);
void OnStateChanged(LobbyEventConnectionState newState)
{
Debug.Log($"State Changed! {newState}");
}
void OnKickedFromLobby()
{
m_CurrentLobby = null;
m_CurrentLocalLobby = null;
OnKicked?.Invoke();
m_LobbyEventCallbacks.LobbyChanged -= ProcessLobbyChanges;
m_LobbyEventCallbacks.KickedFromLobby -= OnKickedFromLobby;
m_LobbyEventCallbacks.LobbyEventConnectionStateChanged -= OnStateChanged;
}
void ProcessLobbyChanges(ILobbyChanges changes)
{
if (changes.LobbyDeleted)
{
#pragma warning disable CS4014
LeaveLobbyAsync();
#pragma warning restore CS4014
return;
}
LobbyFieldChanges(changes, m_CurrentLocalLobby);
CustomLobbyChanged(changes.Data, m_CurrentLocalLobby);
PlayersJoined(changes.PlayerJoined, m_CurrentLocalLobby);
PlayersLeft(changes.PlayerLeft, m_CurrentLocalLobby);
PlayerDataChanged(changes.PlayerData, m_CurrentLocalLobby);
}
void LobbyFieldChanges(ILobbyChanges changes, LocalLobby localLobby)
{
if (changes.Name.Changed)
localLobby.LobbyName.Value = changes.Name.Value;
if (changes.HostId.Changed)
localLobby.HostID.Value = changes.HostId.Value;
if (changes.IsPrivate.Changed)
localLobby.Private.Value = changes.IsPrivate.Value;
if (changes.IsLocked.Changed)
localLobby.Locked.Value = changes.IsLocked.Value;
if (changes.AvailableSlots.Changed)
localLobby.AvailableSlots.Value = changes.AvailableSlots.Value;
if (changes.MaxPlayers.Changed)
localLobby.MaxPlayerCount.Value = changes.MaxPlayers.Value;
if (changes.LastUpdated.Changed)
localLobby.LastUpdated.Value = changes.LastUpdated.Value.ToFileTimeUtc();
}
void CustomLobbyChanged(
ChangedOrRemovedLobbyValue<Dictionary<string, ChangedOrRemovedLobbyValue<DataObject>>> lobbyChanged,
LocalLobby localLobby)
{
if (!lobbyChanged.Changed)
return;
var lobbyChanges = lobbyChanged.Value;
foreach (var change in lobbyChanges)
{
var changedValue = change.Value;
var changedKey = change.Key;
if (changedValue.Removed)
{
if (changedKey == LobbyConverters.key_RelayCode)
localLobby.RelayCode.Value = "";
}
if (changedValue.Changed)
{
ParseCustomLobbyData(changedKey, changedValue.Value);
}
}
void ParseCustomLobbyData(string changedKey, DataObject playerDataObject)
{
if (changedKey == LobbyConverters.key_RelayCode)
localLobby.RelayCode.Value = playerDataObject.Value;
if (changedKey == LobbyConverters.key_LobbyState)
localLobby.LocalLobbyState.Value = (LobbyState)int.Parse(playerDataObject.Value);
if (changedKey == LobbyConverters.key_LobbyColor)
localLobby.LocalLobbyColor.Value = (LobbyColor)int.Parse(playerDataObject.Value);
}
}
void PlayersJoined(ChangedLobbyValue<List<LobbyPlayerJoined>> playersJoinedChanged, LocalLobby localLobby)
{
if (!playersJoinedChanged.Changed)
return;
foreach (var playerChanges in playersJoinedChanged.Value)
{
Player joinedPlayer = playerChanges.Player;
var id = joinedPlayer.Id;
var index = playerChanges.PlayerIndex;
var isHost = localLobby.HostID.Value == id;
var newPlayer = new LocalPlayer(id, index, isHost);
foreach (var dataEntry in joinedPlayer.Data)
{
var dataObject = dataEntry.Value;
ParseCustomPlayerData(newPlayer, dataEntry.Key, dataObject.Value);
}
localLobby.AddPlayer(index, newPlayer);
}
}
void PlayersLeft(ChangedLobbyValue<List<int>> playersLeftChanged, LocalLobby localLobby)
{
if (!playersLeftChanged.Changed)
return;
foreach (var leftPlayerIndex in playersLeftChanged.Value)
{
Debug.Log($"Player {leftPlayerIndex} Left");
localLobby.RemovePlayer(leftPlayerIndex);
}
}
void PlayerDataChanged(ChangedLobbyValue<Dictionary<int, LobbyPlayerChanges>> playerDataChanged,
LocalLobby localLobby)
{
if (!playerDataChanged.Changed)
return;
foreach (var lobbyPlayerChanges in playerDataChanged.Value)
{
var playerIndex = lobbyPlayerChanges.Key;
var localPlayer = localLobby.GetLocalPlayer(playerIndex);
if (localPlayer == null)
continue;
var playerChanges = lobbyPlayerChanges.Value;
if (playerChanges.ConnectionInfoChanged.Changed)
{
var connectionInfo = playerChanges.ConnectionInfoChanged.Value;
Debug.Log(
$"ConnectionInfo for player {playerIndex} changed to {connectionInfo}");
}
if (playerChanges.LastUpdatedChanged.Changed) { }
//There are changes on the Player
if (playerChanges.ChangedData.Changed)
{
foreach (var playerChange in playerChanges.ChangedData.Value)
{
var changedValue = playerChange.Value;
//There are changes on some of the changes in the player list of changes
if (changedValue.Changed)
{
if (changedValue.Removed)
{
Debug.LogWarning("This Sample does not remove Player Values currently.");
continue;
}
var playerDataObject = changedValue.Value;
ParseCustomPlayerData(localPlayer, playerChange.Key, playerDataObject.Value);
}
}
}
}
}
void ParseCustomPlayerData(LocalPlayer player, string dataKey, string playerDataValue)
{
Debug.Log($"RECIEVING : {player.DisplayName.Value}\nDATA : {dataKey} - {playerDataValue}");
if (dataKey == LobbyConverters.key_Emote)
player.Emote.Value = (EmoteType)int.Parse(playerDataValue);
else if (dataKey == LobbyConverters.key_Userstatus)
player.UserStatus.Value = (PlayerStatus)int.Parse(playerDataValue);
else if (dataKey == LobbyConverters.key_Displayname)
player.DisplayName.Value = playerDataValue;
}
#endregion
#region HeartBeat
List<QueryFilter> LobbyColorToFilters(LobbyColor limitToColor)

#endregion
}
//Manages the Amount of times you can hit a service call.
//Adds a buffer to account for ping times.
//Will Queue the latest overflow task for when the cooldown ends.
//Created to mimic the way rate limits are implemented Here: https://docs.unity.com/lobby/rate-limits.html
#region Cooldowns
//Manages the Amount of times you can hit a service call.
//Adds a buffer to account for ping times.
//Will Queue the latest overflow task for when the cooldown ends.
//Created to mimic the way rate limits are implemented Here: https://docs.unity.com/lobby/rate-limits.html
public class ServiceRateLimiter
{
public Action<bool> onCooldownChange;

}
}
}
#endregion
}

2
Packages/manifest.json


"com.unity.render-pipelines.universal": "12.1.6",
"com.unity.services.authentication": "2.2.0",
"com.unity.services.core": "1.4.2",
"com.unity.services.lobby": "1.1.0-pre.3",
"com.unity.services.lobby": "1.0.3",
"com.unity.services.relay": "1.0.5",
"com.unity.services.vivox": "15.1.190400-pre.1",
"com.unity.services.wire": "1.1.1",

7
Packages/packages-lock.json


"url": "https://packages.unity.com"
},
"com.unity.services.lobby": {
"version": "1.1.0-pre.3",
"version": "1.0.3",
"com.unity.services.core": "1.4.2",
"com.unity.services.core": "1.4.0",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
"com.unity.modules.unitywebrequestaudio": "1.0.0",

"com.unity.services.authentication": "2.1.1",
"com.unity.services.wire": "1.1.0"
"com.unity.services.authentication": "2.0.0"
},
"url": "https://packages.unity.com"
},

正在加载...
取消
保存