Skip to content

Commit b0c38c5

Browse files
committed
Extra logs when connecting using Steam
Hopefully should help diagnose some networking issues
1 parent 41fc16c commit b0c38c5

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

Source/Client/Networking/NetworkingSteam.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public void Tick()
134134
var preConnect = playerManager.OnPreConnect(packet.remote);
135135
if (preConnect != null)
136136
{
137+
ServerLog.Log($"Rejected incoming connection from {packet.remote}: {preConnect}");
137138
conn.Close(preConnect.Value);
138139
continue;
139140
}
@@ -149,11 +150,15 @@ public void Tick()
149150

150151
conn.Send(Packets.Server_SteamAccept);
151152
}
152-
153-
if (!packet.joinPacket && player != null)
153+
else if (!packet.joinPacket && player != null)
154154
{
155155
player.HandleReceive(packet.data, packet.reliable);
156156
}
157+
else
158+
{
159+
ServerLog.Error(
160+
$"Received a join packet: {packet.joinPacket} for player: {player} (player should only be null when joinPacket is true)");
161+
}
157162
}
158163
}
159164

@@ -175,13 +180,14 @@ public static void InitCallbacks()
175180
{
176181
p2pFail = Callback<P2PSessionConnectFail_t>.Create(fail =>
177182
{
178-
var session = Multiplayer.session;
179-
if (session == null) return;
180-
181183
var remoteId = fail.m_steamIDRemote;
182184
var error = (EP2PSessionError)fail.m_eP2PSessionError;
185+
ServerLog.Error($"Steam P2P session fail for {remoteId}: {error}");
186+
187+
var session = Multiplayer.session;
188+
if (session == null) return;
183189

184-
if (Multiplayer.Client is SteamBaseConn clientConn && clientConn.remoteId == remoteId)
190+
if (session.client is SteamBaseConn clientConn && clientConn.remoteId == remoteId)
185191
clientConn.OnError(error);
186192

187193
var server = Multiplayer.LocalServer;

Source/Client/Networking/SteamIntegration.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Multiplayer.Client.Networking;
55
using Multiplayer.Client.Util;
66
using Multiplayer.Client.Windows;
7+
using Multiplayer.Common;
78
using RimWorld;
89
using Steamworks;
910
using UnityEngine;
@@ -29,6 +30,7 @@ public static void InitCallbacks()
2930

3031
sessionReq = Callback<P2PSessionRequest_t>.Create(req =>
3132
{
33+
ServerLog.Log($"Received P2P session request from {req.m_steamIDRemote}");
3234
var session = Multiplayer.session;
3335
if (Multiplayer.LocalServer?.settings.steam == true && !session.pendingSteam.Contains(req.m_steamIDRemote))
3436
{

Source/Common/Util/ServerLog.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Multiplayer.Common
44
{
5-
public class ServerLog
5+
public static class ServerLog
66
{
77
public static Action<string>? info;
88
public static Action<string>? error;

0 commit comments

Comments
 (0)