From d1883f25466c5f7099e797a5908e28ca89771c99 Mon Sep 17 00:00:00 2001 From: Babak Samimi Date: Thu, 4 Apr 2019 06:46:24 +0200 Subject: [PATCH 1/2] fix(unet-channels): Invoking .Clear() on two Dictionaries within the Shutdown-function GetConfig() will try to insert new kvp-pairs even though they already exists. Clearing them fixes this and allow, for example, doing StartHost() -> StopHost() -> StartHost() within the same session. --- MLAPI/Data/Transports/UNET/UnetTransport.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MLAPI/Data/Transports/UNET/UnetTransport.cs b/MLAPI/Data/Transports/UNET/UnetTransport.cs index 2f279a4ffd..b31b9398ca 100644 --- a/MLAPI/Data/Transports/UNET/UnetTransport.cs +++ b/MLAPI/Data/Transports/UNET/UnetTransport.cs @@ -31,8 +31,8 @@ public class UnetTransport : Transport private WeakReference temporaryBufferReference; // Lookup / translation - private readonly Dictionary channelNameToId = new Dictionary(); - private readonly Dictionary channelIdToName = new Dictionary(); + private Dictionary channelNameToId = new Dictionary(); + private Dictionary channelIdToName = new Dictionary(); private int serverConnectionId; private int serverHostId; @@ -202,6 +202,8 @@ public override ulong GetCurrentRtt(ulong clientId) public override void Shutdown() { + channelIdToName.Clear(); + channelNameToId.Clear(); NetworkTransport.Shutdown(); } From 1a0390aff89901de8e50056aa258b3bf76c80d3f Mon Sep 17 00:00:00 2001 From: Babak Samimi Date: Thu, 4 Apr 2019 08:47:57 +0200 Subject: [PATCH 2/2] changed the fields back to read-only --- MLAPI/Data/Transports/UNET/UnetTransport.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MLAPI/Data/Transports/UNET/UnetTransport.cs b/MLAPI/Data/Transports/UNET/UnetTransport.cs index b31b9398ca..d5becc2fea 100644 --- a/MLAPI/Data/Transports/UNET/UnetTransport.cs +++ b/MLAPI/Data/Transports/UNET/UnetTransport.cs @@ -31,8 +31,8 @@ public class UnetTransport : Transport private WeakReference temporaryBufferReference; // Lookup / translation - private Dictionary channelNameToId = new Dictionary(); - private Dictionary channelIdToName = new Dictionary(); + private readonly Dictionary channelNameToId = new Dictionary(); + private readonly Dictionary channelIdToName = new Dictionary(); private int serverConnectionId; private int serverHostId;