chore: update naming game -> simple server
This commit is contained in:
Executable
+14
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<targets>
|
||||
<target name="logfile" xsi:type="File" fileName="logs/server-log-${shortdate}.log" layout="[${longdate}][${logger}][${level}] ${message} ${exception:format=ToString}" />
|
||||
<target name="logconsole" xsi:type="Console" layout="[${date}][${logger}][${level}] ${message} ${exception:format=ToString}"/>
|
||||
</targets>
|
||||
|
||||
<rules>
|
||||
<logger name="*" minlevel="Trace" writeTo="logconsole" />
|
||||
<logger name="*" minlevel="Trace" writeTo="logfile" />
|
||||
</rules>
|
||||
</nlog>
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using Game.Source;
|
||||
using Ragon.Core;
|
||||
|
||||
namespace SimpleServer
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var bootstrap = new Bootstrap();
|
||||
bootstrap.Configure(new SimplePluginFactory());
|
||||
|
||||
Console.Read();
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>Game</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="NLog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="config.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Ragon\Ragon.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Source\Managers" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -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