Skip to content

Commit ea2791c

Browse files
committed
fix: passing bufferSize to nanosocket class instead of UdpSocketFactory
allows NanoSocket to be made without UdpSocketFactory
1 parent 75ae51d commit ea2791c

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

Assets/Mirage/Runtime/Sockets/Udp/NanoSocket.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Mirage.Sockets.Udp
88
{
9-
109
public sealed class NanoSocket : ISocket, IDisposable
1110
{
1211
public static bool Supported => true;
@@ -16,9 +15,9 @@ public sealed class NanoSocket : ISocket, IDisposable
1615
private readonly int bufferSize;
1716
private bool needsDisposing;
1817

19-
public NanoSocket(UdpSocketFactory factory)
18+
public NanoSocket(int bufferSize)
2019
{
21-
bufferSize = factory.BufferSize;
20+
this.bufferSize = bufferSize;
2221
}
2322
~NanoSocket()
2423
{

Assets/Mirage/Runtime/Sockets/Udp/UdpSocketFactory.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public override ISocket CreateClientSocket()
8686

8787
if (useNanoSocket)
8888
{
89-
return new NanoSocket(this);
89+
return new NanoSocket(BufferSize);
9090
}
9191
else
9292
{
@@ -100,7 +100,7 @@ public override ISocket CreateServerSocket()
100100

101101
if (useNanoSocket)
102102
{
103-
return new NanoSocket(this);
103+
return new NanoSocket(BufferSize);
104104
}
105105
else
106106
{
@@ -123,8 +123,6 @@ public override IEndPoint GetBindEndPoint()
123123
public override IEndPoint GetConnectEndPoint(string address = null, ushort? port = null)
124124
{
125125
var addressString = address ?? Address;
126-
var ipAddress = getAddress(addressString);
127-
128126
var portIn = port ?? Port;
129127

130128
if (useNanoSocket)
@@ -133,6 +131,7 @@ public override IEndPoint GetConnectEndPoint(string address = null, ushort? port
133131
}
134132
else
135133
{
134+
var ipAddress = getAddress(addressString);
136135
return new EndPointWrapper(new IPEndPoint(ipAddress, portIn));
137136
}
138137
}

0 commit comments

Comments
 (0)