Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Fix command response key leak #1205

Merged
merged 3 commits into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
### Fixed

- Fixed a bug where the Deployment Launcher window would accept tags with 33 characters. [#1202](https://github.com/spatialos/gdk-for-unity/pull/1202)
- Fixed small memory leak with command response callbacks using Monobehaviours. [#1205](https://github.com/spatialos/gdk-for-unity/pull/1205)
zeroZshadow marked this conversation as resolved.
Show resolved Hide resolved

### Internal

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public ulong RegisterCommandRequestCallback<T>(EntityId entityId, Action<T> call
return callbacksRegistered++;
}

public ulong RegisterCommandResponseCallback<T>(long requestId, Action<T> callback)
public void RegisterCommandResponseCallback<T>(long requestId, Action<T> callback)
where T : struct, IReceivedCommandResponse
{
if (!callbackManagers.TryGetManager(typeof(T), out var manager))
Expand All @@ -44,9 +44,7 @@ public ulong RegisterCommandResponseCallback<T>(long requestId, Action<T> callba
callbackManagers.AddCallbackManager(typeof(T), manager);
}

var key = ((CommandResponseCallbackManager<T>) manager).RegisterCallback(requestId, callback);
keyToInternalKeyAndManager.Add(callbacksRegistered, (key, manager));
return callbacksRegistered++;
((CommandResponseCallbackManager<T>) manager).RegisterCallback(requestId, callback);
}

public bool UnregisterCommandRequestCallback(ulong callbackKey)
Expand Down