Skip to content

Commit

Permalink
4.0.0
Browse files Browse the repository at this point in the history
- Fish-Networking 4.0.0 support.
- Added check to prevent Shutdown from calling multiple times without a prior initialization.
- Removed SteamAppId field; this should be handled by third party softwares.
  • Loading branch information
FirstGearGames committed Dec 27, 2023
1 parent 31a66ce commit 340b149
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 38 deletions.
7 changes: 6 additions & 1 deletion FishNet/Plugins/FishySteamworks/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
4.0.0
- Fish-Networking 4.0.0 support.
- Added check to prevent Shutdown from calling multiple times without a prior initialization.
- Removed SteamAppId field; this should be handled by third party softwares.

2.1.2
- Added deinitializer to FishySteamworks.

Expand All @@ -9,7 +14,7 @@
- Fixed ClientId 32767 not found error when being used with Multipass.

1.7.0
- Fish-Networking 2.0.0 Support
- Fish-Networking 2.0.0 support

1.6.0
- GetConnectionAddress now works for clientHost as well.
Expand Down
47 changes: 10 additions & 37 deletions FishNet/Plugins/FishySteamworks/FishySteamworks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ public class FishySteamworks : Transport

#region Serialized.
/// <summary>
/// Steam application Id.
/// </summary>
[Tooltip("Steam application Id.")]
[SerializeField]
private ulong _steamAppID = 480;
/// <summary>
/// Address server should bind to.
/// </summary>
[Tooltip("Address server should bind to.")]
Expand Down Expand Up @@ -81,6 +75,10 @@ public class FishySteamworks : Transport
/// Server for the transport.
/// </summary>
private Server.ServerSocket _server;
/// <summary>
/// True if shutdown had been called, and not initializing nor initialized.
/// </summary>
private bool _shutdownCalled = true;
#endregion

#region Const.
Expand All @@ -99,7 +97,6 @@ public override void Initialize(NetworkManager networkManager, int transportInde
_server = new Server.ServerSocket();

CreateChannelData();
WriteSteamAppId();
_client.Initialize(this);
_clientHost.Initialize(this);
_server.Initialize(this);
Expand Down Expand Up @@ -127,35 +124,6 @@ private void CreateChannelData()
1200
};
}
/// <summary>
/// Writes SteamAppId to file.
/// </summary>
private void WriteSteamAppId()
{
string fileName = "steam_appid.txt";
string appIdText = _steamAppID.ToString();
try
{
if (File.Exists(fileName))
{
string content = File.ReadAllText(fileName);
if (content != appIdText)
{
File.WriteAllText(fileName, appIdText);
Debug.Log($"SteamId has been updated from {content} to {appIdText} within {fileName}.");
}
}
else
{
File.WriteAllText(fileName, appIdText);
Debug.Log($"SteamId {appIdText} has been set within {fileName}.");
}
}
catch (Exception ex)
{
Debug.LogError($"There was an exception when trying to write {appIdText} to {fileName}: {ex.Message}");
}
}

/// <summary>
/// Tries to initialize steam network access.
Expand All @@ -165,12 +133,13 @@ private bool InitializeRelayNetworkAccess()
try
{
#if UNITY_SERVER
SteamGameServerNetworkingUtils.InitRelayNetworkAccess();
SteamGameServerNetworkingUtils.InitRelayNetworkAccess();
#else
SteamNetworkingUtils.InitRelayNetworkAccess();
if (IsNetworkAccessAvailable())
LocalUserSteamID = SteamUser.GetSteamID().m_SteamID;
#endif
_shutdownCalled = false;
return true;
}
catch
Expand Down Expand Up @@ -434,6 +403,10 @@ public override bool StopConnection(int connectionId, bool immediately)
/// </summary>
public override void Shutdown()
{
if (_shutdownCalled)
return;

_shutdownCalled = true;
//Stops client then server connections.
StopConnection(false);
StopConnection(true);
Expand Down

0 comments on commit 340b149

Please sign in to comment.