Skip to content

Commit

Permalink
fix(server): fix visibility of some functions
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMcAssey committed Jan 24, 2025
1 parent cc04ecd commit 9f3b9f4
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 31 deletions.
2 changes: 1 addition & 1 deletion GLOKON.Baiters.Core/ActorSpawner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ActorSpawner(IOptions<WebFishingOptions> _options, BaitersServer server)
spawnProbabilities.Add(ActorType.VoidPortal, (long)(options.Modifiers.VoidPortalChance * 1000));
}

public async Task RunAsync(CancellationToken cancellationToken)
internal async Task RunAsync(CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
{
Expand Down
6 changes: 3 additions & 3 deletions GLOKON.Baiters.Core/BaitersServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public BaitersServer(IOptions<WebFishingOptions> _options)
}
}

public virtual void Setup()
internal virtual void Setup()
{
Log.Information("Setting up server...");

Expand All @@ -140,7 +140,7 @@ public virtual void Setup()
Log.Information("Server setup");
}

public virtual async Task RunAsync(CancellationToken cancellationToken)
internal virtual async Task RunAsync(CancellationToken cancellationToken)
{
if (!string.IsNullOrWhiteSpace(options.CustomLobbyCode))
{
Expand Down Expand Up @@ -192,7 +192,7 @@ public virtual async Task RunAsync(CancellationToken cancellationToken)
}
}

public virtual void Stop()
internal virtual void Stop()
{
Log.Information("Stopping server...");

Expand Down
23 changes: 2 additions & 21 deletions GLOKON.Baiters.Core/NetworkMessageBaitersServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed class NetworkMessageBaitersServer(IOptions<WebFishingOptions> opti
{
private readonly ConcurrentDictionary<ulong, NetIdentity> _connections = new();

public override void Setup()
internal override void Setup()
{
base.Setup();

Expand All @@ -22,7 +22,7 @@ public override void Setup()
SteamNetworkingMessages.OnMessage += SteamNetworkingMessages_OnMessage;
}

public override void Stop()
internal override void Stop()
{
base.Stop();

Expand Down Expand Up @@ -65,25 +65,6 @@ protected override void SendPacketTo(byte[] data, DataChannel channel, ulong ste
}
}

private bool TryGetConnection(ulong steamId, out NetIdentity netIdentity)
{
if (_connections.TryGetValue(steamId, out netIdentity))
{
return true;
}

try
{
_connections.TryAdd(steamId, (NetIdentity)(SteamId)steamId);
return true;
}
catch (Exception ex)
{
Log.Error(ex, "Failed to convert SteamID to NetIdentity for {0}", steamId);
return false;
}
}

private void InternalSendPacket(ulong steamId, NetIdentity netIdentity, byte[] data, DataChannel channel, bool reliable)
{
if (SteamNetworkingMessages.SendMessageToUser(ref netIdentity, data, data.Length, (int)channel, reliable ? SendType.Reliable : SendType.Unreliable) != Result.OK)
Expand Down
2 changes: 1 addition & 1 deletion GLOKON.Baiters.Core/P2PBaitersServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace GLOKON.Baiters.Core
{
public sealed class P2PBaitersServer(IOptions<WebFishingOptions> options) : BaitersServer(options)
{
public override void Setup()
internal override void Setup()
{
base.Setup();

Expand Down
5 changes: 2 additions & 3 deletions GLOKON.Baiters.Core/SocketBaitersServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Steamworks.Data;
using System.Collections.Concurrent;
using System.Runtime.InteropServices;
using System.Security.Principal;

namespace GLOKON.Baiters.Core
{
Expand All @@ -16,13 +15,13 @@ public sealed class SocketBaitersServer(IOptions<WebFishingOptions> options) : B

private SocketManager? _socketManager;

public override Task RunAsync(CancellationToken cancellationToken)
internal override Task RunAsync(CancellationToken cancellationToken)
{
_socketManager = SteamNetworkingSockets.CreateRelaySocket(0, this);
return base.RunAsync(cancellationToken);
}

public override void Stop()
internal override void Stop()
{
if (_socketManager != null)
{
Expand Down
1 change: 0 additions & 1 deletion GLOKON.Baiters.Plugins.ChatCommand/ChatCommandPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using GLOKON.Baiters.Core;
using GLOKON.Baiters.Core.Constants;
using GLOKON.Baiters.Core.Models.Game;
using GLOKON.Baiters.Core.Plugins;
using System.Reflection;

Expand Down
5 changes: 4 additions & 1 deletion PLUGINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

Building plugins for Baiters is really easy!

There is an example plugin on this repository, the ChatCommands plugin, so feel free to use that as a basis.
Save time by using the [plugin template repository](https://github.com/DanielMcAssey/baiters-server-plugin-example) to create your plugin.

Alternatively, there is an example plugin on this repository, the ChatCommands plugin, so feel free to use that as a basis.


## Steps

Expand Down

0 comments on commit 9f3b9f4

Please sign in to comment.