Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6bda468607 |
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"key": "defaultkey",
|
||||
"socket": "udp",
|
||||
"protocol": "1.0.0",
|
||||
"statisticsInterval": 5,
|
||||
"sendRate": 50,
|
||||
|
||||
@@ -16,21 +16,33 @@ namespace Ragon.Core
|
||||
private readonly float _deltaTime = 0.0f;
|
||||
private readonly Configuration _configuration;
|
||||
private readonly RagonSerializer _serializer;
|
||||
|
||||
|
||||
public ISocketServer SocketServer => _socketServer;
|
||||
public Dispatcher Dispatcher => _dispatcher;
|
||||
|
||||
public Application(PluginFactory factory, Configuration configuration)
|
||||
{
|
||||
var authorizationProvider = factory.CreateAuthorizationProvider(configuration);
|
||||
|
||||
|
||||
_configuration = configuration;
|
||||
_serializer = new RagonSerializer();
|
||||
|
||||
|
||||
var dispatcher = new Dispatcher();
|
||||
_dispatcher = dispatcher;
|
||||
|
||||
_socketServer = new ENetServer(this);
|
||||
if (configuration.Socket == "udp")
|
||||
{
|
||||
_socketServer = new ENetServer(this);
|
||||
}
|
||||
else if (configuration.Socket == "websocket")
|
||||
{
|
||||
_socketServer = new WebSocketServer(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Error($"Unknown socket type {configuration.Socket}");
|
||||
}
|
||||
|
||||
_deltaTime = 1000.0f / configuration.SendRate;
|
||||
|
||||
_roomManager = new RoomManager(factory, this);
|
||||
@@ -84,16 +96,16 @@ namespace Ragon.Core
|
||||
Thread.Sleep((int) _deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void OnConnected(ushort peerId)
|
||||
{
|
||||
_logger.Trace("Connected " + peerId);
|
||||
_logger.Trace("Connected " + peerId);
|
||||
}
|
||||
|
||||
public void OnDisconnected(ushort peerId)
|
||||
{
|
||||
_logger.Trace("Disconnected " + peerId);
|
||||
|
||||
|
||||
var player = _lobby.AuthorizationManager.GetPlayer(peerId);
|
||||
if (player != null)
|
||||
_roomManager.Left(player, Array.Empty<byte>());
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Ragon.Core
|
||||
{
|
||||
public string Key;
|
||||
public string Protocol;
|
||||
public string Socket;
|
||||
public int StatisticsInterval;
|
||||
public ushort SendRate;
|
||||
public ushort Port;
|
||||
@@ -18,9 +19,9 @@ namespace Ragon.Core
|
||||
public int MaxConnections;
|
||||
public int MaxPlayersPerRoom;
|
||||
public int MaxRooms;
|
||||
|
||||
|
||||
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly string _serverVersion = "1.0.22-rc";
|
||||
private static readonly string _serverVersion = "1.0.23-rc";
|
||||
|
||||
private static void CopyrightInfo()
|
||||
{
|
||||
|
||||
@@ -197,6 +197,7 @@ public class Entity
|
||||
public void Destroy(ReadOnlySpan<byte> payload)
|
||||
{
|
||||
var serializer = _room.GetSharedSerializer();
|
||||
|
||||
serializer.Clear();
|
||||
serializer.WriteOperation(RagonOperation.DESTROY_ENTITY);
|
||||
serializer.WriteInt(EntityId);
|
||||
@@ -236,7 +237,7 @@ public class Entity
|
||||
var targetMode = (RagonTarget) reader.ReadByte();
|
||||
var payloadData = reader.ReadData(reader.Size);
|
||||
|
||||
Span<byte> payloadRaw = stackalloc byte[reader.Size];
|
||||
Span<byte> payloadRaw = stackalloc byte[payloadData.Length];
|
||||
ReadOnlySpan<byte> payload = payloadRaw;
|
||||
payloadData.CopyTo(payloadRaw);
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ namespace Ragon.Core
|
||||
{
|
||||
var entityId = reader.ReadInt();
|
||||
if (_entities.TryGetValue(entityId, out var entity))
|
||||
{
|
||||
{
|
||||
var player = _players[peerId];
|
||||
var payload = reader.ReadData(reader.Size);
|
||||
DetachEntity(player, entity, payload);
|
||||
|
||||
Reference in New Issue
Block a user