Compare commits
4 Commits
v1.0.22-rc
...
v1.0.25-rc
| Author | SHA1 | Date | |
|---|---|---|---|
| f83d3ea0c7 | |||
| 3564eb2adc | |||
| 3531432758 | |||
| 6bda468607 |
@@ -4,6 +4,7 @@ namespace Ragon.Common
|
|||||||
{
|
{
|
||||||
Owner,
|
Owner,
|
||||||
ExceptOwner,
|
ExceptOwner,
|
||||||
|
ExceptInvoker,
|
||||||
All,
|
All,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"key": "defaultkey",
|
"key": "defaultkey",
|
||||||
|
"socket": "udp",
|
||||||
"protocol": "1.0.0",
|
"protocol": "1.0.0",
|
||||||
"statisticsInterval": 5,
|
"statisticsInterval": 5,
|
||||||
"sendRate": 50,
|
"sendRate": 50,
|
||||||
|
|||||||
@@ -30,7 +30,19 @@ namespace Ragon.Core
|
|||||||
var dispatcher = new Dispatcher();
|
var dispatcher = new Dispatcher();
|
||||||
_dispatcher = 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;
|
_deltaTime = 1000.0f / configuration.SendRate;
|
||||||
|
|
||||||
_roomManager = new RoomManager(factory, this);
|
_roomManager = new RoomManager(factory, this);
|
||||||
@@ -87,7 +99,7 @@ namespace Ragon.Core
|
|||||||
|
|
||||||
public void OnConnected(ushort peerId)
|
public void OnConnected(ushort peerId)
|
||||||
{
|
{
|
||||||
_logger.Trace("Connected " + peerId);
|
_logger.Trace("Connected " + peerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDisconnected(ushort peerId)
|
public void OnDisconnected(ushort peerId)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class AuthorizationManager
|
|||||||
{
|
{
|
||||||
if (_playersByPeers.ContainsKey(peerId))
|
if (_playersByPeers.ContainsKey(peerId))
|
||||||
{
|
{
|
||||||
_logger.Warn($"Connection already authorized {peerId}");
|
_logger.Warn($"Connection already authorized {peerId}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,6 +42,12 @@ public class AuthorizationManager
|
|||||||
|
|
||||||
public void Accepted(ushort peerId, string playerId, string playerName)
|
public void Accepted(ushort peerId, string playerId, string playerName)
|
||||||
{
|
{
|
||||||
|
if (_playersByPeers.ContainsKey(peerId))
|
||||||
|
{
|
||||||
|
_logger.Warn($"Connection already authorized {peerId}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_serializer.Clear();
|
_serializer.Clear();
|
||||||
_serializer.WriteOperation(RagonOperation.AUTHORIZED_SUCCESS);
|
_serializer.WriteOperation(RagonOperation.AUTHORIZED_SUCCESS);
|
||||||
_serializer.WriteString(playerId);
|
_serializer.WriteString(playerId);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace Ragon.Core
|
|||||||
{
|
{
|
||||||
public string Key;
|
public string Key;
|
||||||
public string Protocol;
|
public string Protocol;
|
||||||
|
public string Socket;
|
||||||
public int StatisticsInterval;
|
public int StatisticsInterval;
|
||||||
public ushort SendRate;
|
public ushort SendRate;
|
||||||
public ushort Port;
|
public ushort Port;
|
||||||
@@ -20,7 +21,7 @@ namespace Ragon.Core
|
|||||||
public int MaxRooms;
|
public int MaxRooms;
|
||||||
|
|
||||||
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||||
private static readonly string _serverVersion = "1.0.22-rc";
|
private static readonly string _serverVersion = "1.0.25-rc";
|
||||||
|
|
||||||
private static void CopyrightInfo()
|
private static void CopyrightInfo()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class Entity
|
|||||||
serializer.WriteData(ref payload);
|
serializer.WriteData(ref payload);
|
||||||
|
|
||||||
var sendData = serializer.ToArray();
|
var sendData = serializer.ToArray();
|
||||||
Send(targetMode, sendData);
|
RouteEvent(peerId, targetMode, sendData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReadState(uint peerId, RagonSerializer serializer)
|
public void ReadState(uint peerId, RagonSerializer serializer)
|
||||||
@@ -197,6 +197,7 @@ public class Entity
|
|||||||
public void Destroy(ReadOnlySpan<byte> payload)
|
public void Destroy(ReadOnlySpan<byte> payload)
|
||||||
{
|
{
|
||||||
var serializer = _room.GetSharedSerializer();
|
var serializer = _room.GetSharedSerializer();
|
||||||
|
|
||||||
serializer.Clear();
|
serializer.Clear();
|
||||||
serializer.WriteOperation(RagonOperation.DESTROY_ENTITY);
|
serializer.WriteOperation(RagonOperation.DESTROY_ENTITY);
|
||||||
serializer.WriteInt(EntityId);
|
serializer.WriteInt(EntityId);
|
||||||
@@ -207,7 +208,7 @@ public class Entity
|
|||||||
_room.BroadcastToReady(sendData, DeliveryType.Reliable);
|
_room.BroadcastToReady(sendData, DeliveryType.Reliable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Send(RagonTarget targetMode, byte[] sendData)
|
void RouteEvent(ushort peerId, RagonTarget targetMode, byte[] sendData)
|
||||||
{
|
{
|
||||||
switch (targetMode)
|
switch (targetMode)
|
||||||
{
|
{
|
||||||
@@ -221,6 +222,11 @@ public class Entity
|
|||||||
_room.BroadcastToReady(sendData, new [] { OwnerId }, DeliveryType.Reliable);
|
_room.BroadcastToReady(sendData, new [] { OwnerId }, DeliveryType.Reliable);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case RagonTarget.ExceptInvoker:
|
||||||
|
{
|
||||||
|
_room.BroadcastToReady(sendData, new[] {peerId}, DeliveryType.Reliable);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case RagonTarget.All:
|
case RagonTarget.All:
|
||||||
{
|
{
|
||||||
_room.BroadcastToReady(sendData, DeliveryType.Reliable);
|
_room.BroadcastToReady(sendData, DeliveryType.Reliable);
|
||||||
@@ -236,7 +242,7 @@ public class Entity
|
|||||||
var targetMode = (RagonTarget) reader.ReadByte();
|
var targetMode = (RagonTarget) reader.ReadByte();
|
||||||
var payloadData = reader.ReadData(reader.Size);
|
var payloadData = reader.ReadData(reader.Size);
|
||||||
|
|
||||||
Span<byte> payloadRaw = stackalloc byte[reader.Size];
|
Span<byte> payloadRaw = stackalloc byte[payloadData.Length];
|
||||||
ReadOnlySpan<byte> payload = payloadRaw;
|
ReadOnlySpan<byte> payload = payloadRaw;
|
||||||
payloadData.CopyTo(payloadRaw);
|
payloadData.CopyTo(payloadRaw);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user