]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Remove NetworkConnection.RemoteEndPoint
authorMatthew Endsley <mendsley@gmail.com>
Wed, 3 Feb 2021 10:17:22 +0000 (02:17 -0800)
committerMatthew Endsley <mendsley@gmail.com>
Wed, 3 Feb 2021 22:40:56 +0000 (14:40 -0800)
This field was originally created to provide a non-generic alternative
to the Connection class' EndPoint field. However, we've replaced the
generic ConnectionEndPoint with IPEndPoint in the Connection class.

Since the bas class has a less-generic alias, it is now safe to remove
RemoteEndPoint from NetworkConnection in favor of always using
Connection.EndPoint

Hazel.UnitTests/ThreadLimitedUdpConnectionTests.cs
Hazel.UnitTests/UdpConnectionTests.cs
Hazel.UnitTests/UnityUdpConnectionTests.cs
Hazel/FewerThreads/ThreadLimitedUdpServerConnection.cs
Hazel/NetworkConnection.cs
Hazel/Udp/UdpClientConnection.cs
Hazel/Udp/UdpServerConnection.cs
Hazel/Udp/UnityUdpClientConnection.cs

index b9a3a0a7816d4b93c4c2dd46febb1898110998aa..a5c3fa6a095debd8a473d35781316ac0a07728a2 100644 (file)
@@ -1,4 +1,4 @@
-using System;
+using System;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using System.Net;
 using System.Threading;
@@ -96,7 +96,7 @@ namespace Hazel.UnitTests
                 Assert.AreEqual(ep, connection.EndPoint);
 
                 //UdpConnection fields
-                Assert.AreEqual(new IPEndPoint(IPAddress.Loopback, 4296), connection.RemoteEndPoint);
+                Assert.AreEqual(new IPEndPoint(IPAddress.Loopback, 4296), connection.EndPoint);
                 Assert.AreEqual(1, connection.Statistics.DataBytesSent);
                 Assert.AreEqual(0, connection.Statistics.DataBytesReceived);
             }
index 73017d745ee866261361cda9b73d56a6f9ad1690..2421268f1ed99ed876f6464848ef299dd2e4a4c7 100644 (file)
@@ -1,4 +1,4 @@
-using System;
+using System;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using System.Net;
 using System.Threading;
@@ -95,7 +95,7 @@ namespace Hazel.UnitTests
                 Assert.AreEqual(ep, connection.EndPoint);
 
                 //UdpConnection fields
-                Assert.AreEqual(new IPEndPoint(IPAddress.Loopback, 4296), connection.RemoteEndPoint);
+                Assert.AreEqual(new IPEndPoint(IPAddress.Loopback, 4296), connection.EndPoint);
                 Assert.AreEqual(1, connection.Statistics.DataBytesSent);
                 Assert.AreEqual(0, connection.Statistics.DataBytesReceived);
             }
index 5b84bbe6025a1a434b53dfb3a6934f4ae0f8b2e9..4f989c569ea3406c4adb5e38c1ad44d27f3f15ae 100644 (file)
@@ -1,4 +1,4 @@
-using System;
+using System;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using System.Net;
 using System.Threading;
@@ -95,7 +95,7 @@ namespace Hazel.UnitTests
                 Assert.AreEqual(ep, connection.EndPoint);
 
                 //UdpConnection fields
-                Assert.AreEqual(new IPEndPoint(IPAddress.Loopback, 4296), connection.RemoteEndPoint);
+                Assert.AreEqual(new IPEndPoint(IPAddress.Loopback, 4296), connection.EndPoint);
                 Assert.AreEqual(1, connection.Statistics.DataBytesSent);
                 Assert.AreEqual(0, connection.Statistics.DataBytesReceived);
             }
index 149ab9eb812af1ae73a6f17bea756a933929b206..0cb864f12cdbd7838e25cd61e02de24ff032854e 100644 (file)
@@ -33,7 +33,6 @@ namespace Hazel.Udp.FewerThreads
         {
             this.Listener = listener;
             this.ConnectionId = connectionId;
-            this.RemoteEndPoint = endPoint;
             this.EndPoint = endPoint;
             this.IPMode = IPMode;
 
index 58915b73c31713e3dbece4864d68e8bc21f90255..979950938a4ed6da7d32a42d367f1c6435044990 100644 (file)
@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Net;
@@ -28,26 +28,17 @@ namespace Hazel
         /// </summary>
         public Func<HazelInternalErrors, MessageWriter> OnInternalDisconnect;
 
-        /// <summary>
-        ///     The remote end point of this connection.
-        /// </summary>
-        /// <remarks>
-        ///     This is the end point of the other device given as an <see cref="System.Net.EndPoint"/> rather than a generic
-        ///     <see cref="ConnectionEndPoint"/> as the base <see cref="Connection"/> does.
-        /// </remarks>
-        public EndPoint RemoteEndPoint { get; protected set; }
-
         public virtual float AveragePingMs { get; }
 
         public long GetIP4Address()
         {
             if (IPMode == IPMode.IPv4)
             {
-                return ((IPEndPoint)this.RemoteEndPoint).Address.Address;
+                return this.EndPoint.Address.Address;
             }
             else
             {
-                var bytes = ((IPEndPoint)this.RemoteEndPoint).Address.GetAddressBytes();
+                var bytes = this.EndPoint.Address.GetAddressBytes();
                 return BitConverter.ToInt64(bytes, bytes.Length - 8);
             }
         }
index af932866fcc9e7d10fb2291b5450b6bf9e5a6374..072bc6d622a006f452b3c4d389eadd7f7623d716 100644 (file)
@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Net;
 using System.Net.Sockets;
 using System.Threading;
@@ -37,7 +37,6 @@ namespace Hazel.Udp
             : base()
         {
             this.EndPoint = remoteEndPoint;
-            this.RemoteEndPoint = remoteEndPoint;
             this.IPMode = ipMode;
 
             this.socket = CreateSocket(ipMode);
@@ -89,7 +88,7 @@ namespace Hazel.Udp
                     0,
                     length,
                     SocketFlags.None,
-                    RemoteEndPoint,
+                    EndPoint,
                     HandleSendTo,
                     null);
             }
@@ -318,7 +317,7 @@ namespace Hazel.Udp
                     0,
                     bytes.Length,
                     SocketFlags.None,
-                    RemoteEndPoint);
+                    EndPoint);
             }
             catch { }
 
@@ -343,4 +342,4 @@ namespace Hazel.Udp
             base.Dispose(disposing);
         }
     }
-}
\ No newline at end of file
+}
index 32093c17924b1c7bae7ebb5472783ed4eeab50c1..f348adbd30af4409e300cd79d450c53c6afd27a7 100644 (file)
@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Net;
 
 namespace Hazel.Udp
@@ -28,7 +28,6 @@ namespace Hazel.Udp
             : base()
         {
             this.Listener = listener;
-            this.RemoteEndPoint = endPoint;
             this.EndPoint = endPoint;
             this.IPMode = IPMode;
 
@@ -39,7 +38,7 @@ namespace Hazel.Udp
         /// <inheritdoc />
         protected override void WriteBytesToConnection(byte[] bytes, int length)
         {
-            Listener.SendData(bytes, length, RemoteEndPoint);
+            Listener.SendData(bytes, length, EndPoint);
         }
 
         /// <inheritdoc />
@@ -82,7 +81,7 @@ namespace Hazel.Udp
 
             try
             {
-                Listener.SendDataSync(bytes, bytes.Length, RemoteEndPoint);
+                Listener.SendDataSync(bytes, bytes.Length, EndPoint);
             }
             catch { }
 
@@ -91,7 +90,7 @@ namespace Hazel.Udp
 
         protected override void Dispose(bool disposing)
         {
-            Listener.RemoveConnectionTo(RemoteEndPoint);
+            Listener.RemoveConnectionTo(EndPoint);
 
             if (disposing)
             {
index eb9264bc49cd517bf206acd13dfefff681a7816b..8b501802c184c1f71dbae76b793d81c46cb54063 100644 (file)
@@ -19,7 +19,6 @@ namespace Hazel.Udp
             : base()
         {
             this.EndPoint = remoteEndPoint;
-            this.RemoteEndPoint = remoteEndPoint;
             this.IPMode = ipMode;
 
             this.socket = CreateSocket(ipMode);
@@ -55,7 +54,7 @@ namespace Hazel.Udp
                     0,
                     length,
                     SocketFlags.None,
-                    RemoteEndPoint,
+                    EndPoint,
                     HandleSendTo,
                     null);
             }
@@ -153,7 +152,7 @@ namespace Hazel.Udp
             var msg = MessageReader.GetSized(ushort.MaxValue);
             try
             {
-                var ep = this.RemoteEndPoint;
+                EndPoint ep = this.EndPoint;
                 socket.BeginReceiveFrom(msg.Buffer, 0, msg.Buffer.Length, SocketFlags.None, ref ep, ReadCallback, msg);
             }
             catch
@@ -173,7 +172,7 @@ namespace Hazel.Udp
 
             try
             {
-                var ep = this.RemoteEndPoint;
+                EndPoint ep = this.EndPoint;
                 msg.Length = socket.EndReceiveFrom(result, ref ep);
             }
             catch (SocketException e)