chore: update naming game -> simple server
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using Ragon.Core;
|
||||
|
||||
namespace Game.Source;
|
||||
|
||||
public class AuthorizerByKey: AuthorizationManager
|
||||
{
|
||||
private Configuration _configuration;
|
||||
public AuthorizerByKey(Configuration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public override bool OnAuthorize(uint peerId, ref ReadOnlySpan<byte> payload)
|
||||
{
|
||||
var key = Encoding.UTF8.GetString(payload);
|
||||
return _configuration.Key == key;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using NetStack.Serialization;
|
||||
using Ragon.Common;
|
||||
|
||||
namespace Game.Source.Events;
|
||||
|
||||
public class SimpleEvent: IRagonSerializable
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public void Serialize(BitBuffer buffer)
|
||||
{
|
||||
buffer.AddString(Name);
|
||||
}
|
||||
|
||||
public void Deserialize(BitBuffer buffer)
|
||||
{
|
||||
Name = buffer.ReadString();
|
||||
}
|
||||
}
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using Game.Source.Events;
|
||||
using NLog;
|
||||
using Ragon.Common;
|
||||
using Ragon.Core;
|
||||
|
||||
namespace Game.Source
|
||||
{
|
||||
public class SimplePlugin: PluginBase
|
||||
{
|
||||
public override void OnStart()
|
||||
{
|
||||
_logger.Info("Plugin started");
|
||||
}
|
||||
|
||||
public override void OnStop()
|
||||
{
|
||||
_logger.Info("Plugin stopped");
|
||||
}
|
||||
|
||||
public override void OnPlayerJoined(Player player)
|
||||
{
|
||||
_logger.Info("Player joined " + player.PlayerName);
|
||||
}
|
||||
|
||||
public override void OnPlayerLeaved(Player player)
|
||||
{
|
||||
_logger.Info("Player leaved " + player.PlayerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using Ragon.Core;
|
||||
|
||||
namespace Game.Source
|
||||
{
|
||||
public class SimplePluginFactory : PluginFactory
|
||||
{
|
||||
public string PluginName { get; set; } = "SimplePlugin";
|
||||
public PluginBase CreatePlugin(string map)
|
||||
{
|
||||
|
||||
return new SimplePlugin();
|
||||
}
|
||||
|
||||
public AuthorizationManager CreateManager(Configuration configuration)
|
||||
{
|
||||
return new AuthorizerByKey(configuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user