Skip to content
This repository was archived by the owner on Sep 15, 2024. It is now read-only.

Commit dbd9140

Browse files
Make use of IDisposable
1 parent 1a470a3 commit dbd9140

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Scripts/Netcode/Web/WebClient.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace GodotModules.Netcode
1414
{
15-
public class WebClient
15+
public class WebClient : IDisposable
1616
{
1717
public HttpClient Client { get; set; }
1818
public static string ExternalIp { get; set; }
@@ -116,6 +116,11 @@ public static void GetExternalIp()
116116
string externalIpString = new System.Net.WebClient().DownloadString("http://icanhazip.com").Replace("\\r\\n", "").Replace("\\n", "").Trim();
117117
ExternalIp = IPAddress.Parse(externalIpString).ToString();
118118
}
119+
120+
public void Dispose()
121+
{
122+
Client.Dispose();
123+
}
119124
}
120125

121126
public struct WebServerResponse<T>

Scripts/Scenes/Main/NetworkManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private static async Task ExitCleanup()
113113
}
114114

115115
UtilOptions.SaveOptions();
116-
WebClient.Client.Dispose();
116+
WebClient.Dispose();
117117

118118
ClientConnectingTokenSource?.Dispose();
119119

0 commit comments

Comments
 (0)