Skip to content

Commit 091a51b

Browse files
Tyro-GamesTyro-Games
authored andcommitted
Bump FN 4.16
1 parent 17f7e7f commit 091a51b

File tree

3 files changed

+26
-46
lines changed

3 files changed

+26
-46
lines changed

FishNet/Plugins/FishyFacepunch/Core/ClientSocket.cs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System;
77
using System.Threading;
88
using System.Threading.Tasks;
9+
using FishNet.Managing;
910
using UnityEngine;
1011

1112
namespace FishyFacepunch.Client
@@ -87,45 +88,39 @@ internal async void StartConnection(string address, ushort port)
8788
{
8889
if (cancelToken.IsCancellationRequested)
8990
{
90-
if (base.Transport.NetworkManager.CanLog(LoggingType.Error))
91-
Debug.LogError($"The connection attempt was cancelled.");
91+
Transport.NetworkManager.LogError($"The connection attempt was cancelled.");
9292
}
9393
else if (timeOutTask.IsCompleted)
9494
{
95-
if (base.Transport.NetworkManager.CanLog(LoggingType.Error))
96-
Debug.LogError($"Connection to {address} timed out.");
95+
Transport.NetworkManager.LogError($"Connection to {address} timed out.");
9796
StopConnection();
9897
}
9998
SetLocalConnectionState(LocalConnectionState.Stopped, false);
10099
}
101100
}
102101
else
103102
{
104-
if (base.Transport.NetworkManager.CanLog(LoggingType.Error))
105-
Debug.LogError("SteamWorks not initialized");
103+
Transport.NetworkManager.LogError("SteamWorks not initialized");
106104
SetLocalConnectionState(LocalConnectionState.Stopped, false);
107105
}
108106
}
109107
catch (FormatException)
110108
{
111-
if (base.Transport.NetworkManager.CanLog(LoggingType.Error))
112-
Debug.LogError($"Connection string was not in the right format. Did you enter a SteamId?");
109+
Transport.NetworkManager.LogError($"Connection string was not in the right format. Did you enter a SteamId?");
113110
SetLocalConnectionState(LocalConnectionState.Stopped, false);
114111
_Error = true;
115112
}
116113
catch (Exception ex)
117114
{
118-
if (base.Transport.NetworkManager.CanLog(LoggingType.Error))
119-
Debug.LogError(ex.Message);
115+
Transport.NetworkManager.LogError(ex.Message);
120116
SetLocalConnectionState(LocalConnectionState.Stopped, false);
121117
_Error = true;
122118
}
123119
finally
124120
{
125121
if (_Error)
126122
{
127-
if (base.Transport.NetworkManager.CanLog(LoggingType.Error))
128-
Debug.LogError("Connection failed.");
123+
Transport.NetworkManager.LogError("Connection failed.");
129124
SetLocalConnectionState(LocalConnectionState.Stopped, false);
130125
}
131126
}
@@ -143,14 +138,12 @@ private void OnConnectionStatusChanged(Connection conn, ConnectionInfo info)
143138
}
144139
else if (info.State == ConnectionState.ClosedByPeer || info.State == ConnectionState.ProblemDetectedLocally)
145140
{
146-
if (base.Transport.NetworkManager.CanLog(LoggingType.Common))
147-
Debug.Log($"Connection was closed by peer, {info.EndReason}");
141+
Transport.NetworkManager.Log($"Connection was closed by peer, {info.EndReason}");
148142
StopConnection();
149143
}
150144
else
151145
{
152-
if (base.Transport.NetworkManager.CanLog(LoggingType.Common))
153-
Debug.Log($"Connection state changed: {info.State.ToString()} - {info.EndReason}");
146+
Transport.NetworkManager.Log($"Connection state changed: {info.State.ToString()} - {info.EndReason}");
154147
}
155148
}
156149

@@ -171,8 +164,7 @@ internal bool StopConnection()
171164

172165
if (HostConnectionManager != null)
173166
{
174-
if (base.Transport.NetworkManager.CanLog(LoggingType.Common))
175-
Debug.Log("Sending Disconnect message");
167+
Transport.NetworkManager.Log("Sending Disconnect message");
176168
HostConnection.Close(false, 0, "Graceful disconnect");
177169
HostConnectionManager = null;
178170
}
@@ -212,14 +204,12 @@ internal void SendToServer(byte channelId, ArraySegment<byte> segment)
212204
Result res = base.Send(HostConnection, segment, channelId);
213205
if (res == Result.NoConnection || res == Result.InvalidParam)
214206
{
215-
if (base.Transport.NetworkManager.CanLog(LoggingType.Common))
216-
Debug.Log($"Connection to server was lost.");
207+
Transport.NetworkManager.Log($"Connection to server was lost.");
217208
StopConnection();
218209
}
219210
else if (res != Result.OK)
220211
{
221-
if (base.Transport.NetworkManager.CanLog(LoggingType.Error))
222-
Debug.LogError($"Could not send: {res.ToString()}");
212+
Transport.NetworkManager.LogError($"Could not send: {res.ToString()}");
223213
}
224214
}
225215

FishNet/Plugins/FishyFacepunch/Core/CommonSocket.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Collections.Generic;
88
using System.Net;
99
using System.Runtime.InteropServices;
10+
using FishNet.Managing;
1011
using UnityEngine;
1112

1213
namespace FishyFacepunch
@@ -150,8 +151,7 @@ protected Result Send(Connection conn, ArraySegment<byte> segment, byte channelI
150151
Result result = conn.SendMessage(pData, segment.Count, sendFlag);
151152
if (result != Result.OK)
152153
{
153-
if (Transport.NetworkManager.CanLog(LoggingType.Warning))
154-
Debug.LogWarning($"Send issue: {result}");
154+
Transport.NetworkManager.LogWarning($"Send issue: {result}");
155155
}
156156

157157
pinnedArray.Free();

FishNet/Plugins/FishyFacepunch/Core/ServerSocket.cs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Steamworks.Data;
77
using System;
88
using System.Collections.Generic;
9+
using FishNet.Managing;
910
using UnityEngine;
1011

1112
namespace FishyFacepunch.Server
@@ -167,8 +168,7 @@ internal bool StopConnection(int connectionId)
167168
}
168169
else
169170
{
170-
if (base.Transport.NetworkManager.CanLog(LoggingType.Error))
171-
Debug.LogError($"Steam connection not found for connectionId {connectionId}.");
171+
Transport.NetworkManager.LogError($"Steam connection not found for connectionId {connectionId}.");
172172
return false;
173173
}
174174
}
@@ -183,8 +183,7 @@ private bool StopConnection(int connectionId, Connection socket)
183183
socket.Close(false, 0, "Graceful disconnect");
184184
_steamConnections.Remove(connectionId);
185185
_steamIds.Remove(connectionId);
186-
if (base.Transport.NetworkManager.CanLog(LoggingType.Common))
187-
Debug.Log($"Client with ConnectionID {connectionId} disconnected.");
186+
Transport.NetworkManager.Log($"Client with ConnectionID {connectionId} disconnected.");
188187
base.Transport.HandleRemoteConnectionState(new RemoteConnectionStateArgs(RemoteConnectionState.Stopped, connectionId, Transport.Index));
189188
_cachedConnectionIds.Enqueue(connectionId);
190189

@@ -201,8 +200,7 @@ private void OnRemoteConnectionState(Connection conn, ConnectionInfo info)
201200
{
202201
if (_steamConnections.Count >= _maximumClients)
203202
{
204-
if (base.Transport.NetworkManager.CanLog(LoggingType.Common))
205-
Debug.Log($"Incoming connection {clientSteamID} was rejected because would exceed the maximum connection count.");
203+
Transport.NetworkManager.Log($"Incoming connection {clientSteamID} was rejected because would exceed the maximum connection count.");
206204

207205
conn.Close(false, 0, "Max Connection Count");
208206
return;
@@ -212,13 +210,11 @@ private void OnRemoteConnectionState(Connection conn, ConnectionInfo info)
212210

213211
if ((res = conn.Accept()) == Result.OK)
214212
{
215-
if (base.Transport.NetworkManager.CanLog(LoggingType.Common))
216-
Debug.Log($"Accepting connection {clientSteamID}");
213+
Transport.NetworkManager.Log($"Accepting connection {clientSteamID}");
217214
}
218215
else
219216
{
220-
if (base.Transport.NetworkManager.CanLog(LoggingType.Common))
221-
Debug.Log($"Connection {clientSteamID} could not be accepted: {res.ToString()}");
217+
Transport.NetworkManager.Log($"Connection {clientSteamID} could not be accepted: {res.ToString()}");
222218
}
223219
}
224220
else if (info.State == ConnectionState.Connected)
@@ -227,8 +223,7 @@ private void OnRemoteConnectionState(Connection conn, ConnectionInfo info)
227223
_steamConnections.Add(conn, connectionId);
228224
_steamIds.Add(clientSteamID, connectionId);
229225

230-
if (base.Transport.NetworkManager.CanLog(LoggingType.Common))
231-
Debug.Log($"Client with SteamID {clientSteamID} connected. Assigning connection id {connectionId}");
226+
Transport.NetworkManager.Log($"Client with SteamID {clientSteamID} connected. Assigning connection id {connectionId}");
232227
base.Transport.HandleRemoteConnectionState(new RemoteConnectionStateArgs(RemoteConnectionState.Started, connectionId, Transport.Index));
233228
}
234229
else if (info.State == ConnectionState.ClosedByPeer || info.State == ConnectionState.ProblemDetectedLocally)
@@ -240,8 +235,7 @@ private void OnRemoteConnectionState(Connection conn, ConnectionInfo info)
240235
}
241236
else
242237
{
243-
if (base.Transport.NetworkManager.CanLog(LoggingType.Common))
244-
Debug.Log($"Connection {clientSteamID} state changed: {info.State.ToString()}");
238+
Transport.NetworkManager.Log($"Connection {clientSteamID} state changed: {info.State.ToString()}");
245239
}
246240
}
247241

@@ -316,20 +310,17 @@ internal void SendToClient(byte channelId, ArraySegment<byte> segment, int conne
316310

317311
if (res == Result.NoConnection || res == Result.InvalidParam)
318312
{
319-
if (base.Transport.NetworkManager.CanLog(LoggingType.Common))
320-
Debug.Log($"Connection to {connectionId} was lost.");
313+
Transport.NetworkManager.Log($"Connection to {connectionId} was lost.");
321314
StopConnection(connectionId, steamConn);
322315
}
323316
else if (res != Result.OK)
324317
{
325-
if (base.Transport.NetworkManager.CanLog(LoggingType.Error))
326-
Debug.LogError($"Could not send: {res.ToString()}");
318+
Transport.NetworkManager.LogError($"Could not send: {res.ToString()}");
327319
}
328320
}
329321
else
330322
{
331-
if (base.Transport.NetworkManager.CanLog(LoggingType.Error))
332-
Debug.LogError($"ConnectionId {connectionId} does not exist, data will not be sent.");
323+
Transport.NetworkManager.LogError($"ConnectionId {connectionId} does not exist, data will not be sent.");
333324
}
334325
}
335326

@@ -346,8 +337,7 @@ internal string GetConnectionAddress(int connectionId)
346337
}
347338
else
348339
{
349-
if (base.Transport.NetworkManager.CanLog(LoggingType.Error))
350-
Debug.LogError($"ConnectionId {connectionId} is invalid; address cannot be returned.");
340+
Transport.NetworkManager.LogError($"ConnectionId {connectionId} is invalid; address cannot be returned.");
351341

352342
return string.Empty;
353343
}

0 commit comments

Comments
 (0)