浏览代码

Adding rate limit behavior for the Join button, so it will also fade while within the rate limit for joining lobbies.

Seems like at some point here, I've lost all non-manual list refreshing except when coming from the main menu? I.e. when quitting a lobby, the list doesn't refresh, since it's still within the rate limit for the lobby but we don't (and shouldn't?) cache the refresh call for the list.
/main/staging/rate_limit_data
nathaniel.buck@unity3d.com 3 年前
当前提交
691a48ab
共有 5 个文件被更改,包括 84 次插入53 次删除
  1. 45
      Assets/Prefabs/UI/JoinContent.prefab
  2. 56
      Assets/Prefabs/UI/JoinCreateCanvas.prefab
  3. 8
      Assets/Scenes/mainScene.unity
  4. 9
      Assets/Scripts/Game/LocalGameState.cs
  5. 19
      Assets/Scripts/Lobby/LobbyAsyncRequests.cs

45
Assets/Prefabs/UI/JoinContent.prefab


- component: {fileID: 4781496634016831221}
- component: {fileID: 433211913614645534}
- component: {fileID: 2049737766857408132}
- component: {fileID: 3395876640994339088}
- component: {fileID: 2856360851590408532}
- component: {fileID: 4536627014072050652}
m_Layer: 5
m_Name: JoinButton
m_TagString: Untagged

m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
--- !u!225 &3395876640994339088
CanvasGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8940655666626669338}
m_Enabled: 1
m_Alpha: 1
m_Interactable: 1
m_BlocksRaycasts: 1
m_IgnoreParentGroups: 0
--- !u!114 &2856360851590408532
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8940655666626669338}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ab355d5994635724dbde297a055fb586, type: 3}
m_Name:
m_EditorClassIdentifier:
m_onVisibilityChange:
m_PersistentCalls:
m_Calls: []
--- !u!114 &4536627014072050652
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8940655666626669338}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 771ddda4ce2ee2a4dad57866ecc1170d, type: 3}
m_Name:
m_EditorClassIdentifier:
m_target: {fileID: 2856360851590408532}
m_alphaWhenHidden: 0.5
m_requestType: 1
--- !u!1 &9182743073287606781
GameObject:
m_ObjectHideFlags: 0

56
Assets/Prefabs/UI/JoinCreateCanvas.prefab


m_Modification:
m_TransformParent: {fileID: 1119140321553661053}
m_Modifications:
- target: {fileID: 1079176168591545865, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size
value: 2
objectReference: {fileID: 0}
- target: {fileID: 1079176168591545865, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_Mode
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1079176168591545865, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_Target
value:
objectReference: {fileID: 4578721078997909056}
- target: {fileID: 1079176168591545865, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_CallState
value: 2
objectReference: {fileID: 0}
- target: {fileID: 1079176168591545865, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_MethodName
value: Hide
objectReference: {fileID: 0}
- target: {fileID: 1079176168591545865, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_TargetAssemblyTypeName
value: LobbyRooms.UI.UIPanelBase, LobbyRooms
objectReference: {fileID: 0}
- target: {fileID: 1079176168591545865, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_Arguments.m_ObjectArgumentAssemblyTypeName
value: UnityEngine.Object, UnityEngine
objectReference: {fileID: 0}
- target: {fileID: 3939988936382120653, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_AnchoredPosition.y
value: -0.5
objectReference: {fileID: 0}
- target: {fileID: 4388255649222666380, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_AnchorMax.y
value: 0

propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5860664165358648575, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_VerticalAlignment
value: 512
objectReference: {fileID: 0}
- target: {fileID: 5860664165358648575, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_HorizontalAlignment
value: 2
- target: {fileID: 5912780227213918576, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_fontSize
value: 18
objectReference: {fileID: 0}
- target: {fileID: 5962604622760643426, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_AnchorMax.y

propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8270614565048916457, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_Alpha
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8270614565048916457, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_Interactable
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8533460643281418118, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_AnchorMax.y
value: 0

m_Modifications:
- target: {fileID: 433211913614645534, guid: c308ffc2a02e5ab4bbe70a8b2e8108c6, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size
value: 2
value: 1
objectReference: {fileID: 0}
- target: {fileID: 433211913614645534, guid: c308ffc2a02e5ab4bbe70a8b2e8108c6, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[1].m_Mode

- target: {fileID: 7315760059761538639, guid: c308ffc2a02e5ab4bbe70a8b2e8108c6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7522528203600751071, guid: c308ffc2a02e5ab4bbe70a8b2e8108c6, type: 3}
propertyPath: m_Size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7573825319354851387, guid: c308ffc2a02e5ab4bbe70a8b2e8108c6, type: 3}
propertyPath: m_AnchorMax.x

8
Assets/Scenes/mainScene.unity


propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2637199316974547451, guid: f1d618bdc6f1813449d428126e640aa5, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2637199317172016808, guid: f1d618bdc6f1813449d428126e640aa5, type: 3}
propertyPath: m_IsActive
value: 1

- target: {fileID: 2866784668895171917, guid: f1d618bdc6f1813449d428126e640aa5, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2918310285625255774, guid: f1d618bdc6f1813449d428126e640aa5, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2995192838028648417, guid: f1d618bdc6f1813449d428126e640aa5, type: 3}
propertyPath: m_AnchorMax.y

9
Assets/Scripts/Game/LocalGameState.cs


get => m_State;
set
{
m_State = value;
OnChanged(this);
if (m_State != value)
{
m_State = value;
OnChanged(this);
}
if (m_State == oldObserved.State)
return;
m_State = oldObserved.State;
OnChanged(this);
}

19
Assets/Scripts/Lobby/LobbyAsyncRequests.cs


#endregion
#region Lobby API calls are rate limited, and some other operations might want to know when the rate limits have passed.
public enum RequestType { Query = 0 }
#region Lobby API calls are rate limited, and some other operations might want an alert when the rate limits have passed.
// Note that some APIs limit to 1 call per N seconds, while others limit to M calls per N seconds. We'll treat all APIs as though they limited to 1 call per N seconds.
public enum RequestType { Query = 0, Join }
if (type == RequestType.Join)
return m_rateLimitJoin;
private RateLimitCooldown m_rateLimitQuery = new RateLimitCooldown(1.5f);
private RateLimitCooldown m_rateLimitQuery = new RateLimitCooldown(1.5f); // Used for both the lobby list UI and the in-lobby updating. In the latter case, updates can be cached.
private RateLimitCooldown m_rateLimitJoin = new RateLimitCooldown(3f);
// TODO: Shift to using this to do rate limiting for all API calls? E.g. the
#endregion
private static Dictionary<string, PlayerDataObject> CreateInitialPlayerData(LobbyUser player)

/// </summary>
public void JoinLobbyAsync(string lobbyId, string lobbyCode, LobbyUser localUser, Action<Lobby> onSuccess, Action onFailure)
{
if (!m_rateLimitJoin.CanCall() ||
(lobbyId == null && lobbyCode == null))
{
onFailure?.Invoke();
// TODO: Emit some failure message.
return;
}
string uasId = AuthenticationService.Instance.PlayerId;
if (!string.IsNullOrEmpty(lobbyId))
LobbyAPIInterface.JoinLobbyAsync_ById(uasId, lobbyId, CreateInitialPlayerData(localUser), OnLobbyJoined);

正在加载...
取消
保存