feat: room properties ready, player properties wip
This commit is contained in:
@@ -41,6 +41,7 @@ public sealed class AuthorizationOperation: BaseOperation
|
||||
_webhook = webhook;
|
||||
_observer = observer;
|
||||
_writer = writer;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public override void Handle(RagonContext context, NetworkChannel channel)
|
||||
|
||||
+4
-6
@@ -5,11 +5,11 @@ using Ragon.Server.Lobby;
|
||||
|
||||
namespace Ragon.Server.Handler
|
||||
{
|
||||
public class PlayerDataOperation : BaseOperation
|
||||
public class PlayerPropertiesOperation : BaseOperation
|
||||
{
|
||||
private readonly ILogger _logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public PlayerDataOperation(RagonBuffer reader, RagonBuffer writer) : base(reader, writer)
|
||||
public PlayerPropertiesOperation(RagonBuffer reader, RagonBuffer writer) : base(reader, writer)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -20,10 +20,8 @@ namespace Ragon.Server.Handler
|
||||
_logger.Warn($"Player {context.Connection.Id} not authorized for this request");
|
||||
return;
|
||||
}
|
||||
|
||||
var playerDataLen = Reader.ReadUShort();
|
||||
var playerData = Reader.ReadBytes(playerDataLen);
|
||||
|
||||
|
||||
var playerData = Reader.ReadBytes(Reader.Capacity);
|
||||
context.UserData.Data = playerData;
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using NLog;
|
||||
using Ragon.Protocol;
|
||||
using Ragon.Server.IO;
|
||||
|
||||
@@ -27,11 +28,22 @@ public sealed class RoomDataOperation : BaseOperation
|
||||
|
||||
public override void Handle(RagonContext context, NetworkChannel channel)
|
||||
{
|
||||
var playerDataLen = Reader.ReadUShort();
|
||||
var playerData = Reader.ReadBytes(playerDataLen);
|
||||
|
||||
var player = context.RoomPlayer;
|
||||
var room = context.Room;
|
||||
if (room != null)
|
||||
room.UserData.Data = playerData;
|
||||
|
||||
var data = Reader.RawData;
|
||||
var dataSize = data.Length - 1;
|
||||
var headerSize = 3;
|
||||
var size = headerSize + dataSize;
|
||||
var sendData = new byte[size];
|
||||
var peerId = player.Connection.Id;
|
||||
|
||||
sendData[0] = (byte)RagonOperation.REPLICATE_RAW_DATA;
|
||||
sendData[1] = (byte)peerId;
|
||||
sendData[2] = (byte)(peerId >> 8);
|
||||
|
||||
Array.Copy(data, 1, sendData, headerSize, dataSize);
|
||||
|
||||
room.Broadcast(sendData, channel);
|
||||
}
|
||||
}
|
||||
+15
-18
@@ -17,33 +17,30 @@
|
||||
using NLog;
|
||||
using Ragon.Protocol;
|
||||
using Ragon.Server.IO;
|
||||
using Ragon.Server.Lobby;
|
||||
|
||||
namespace Ragon.Server.Handler;
|
||||
|
||||
public sealed class RoomRawDataOperation : BaseOperation
|
||||
public sealed class RoomPropertiesOperation : BaseOperation
|
||||
{
|
||||
public RoomRawDataOperation(RagonBuffer reader, RagonBuffer writer) : base(reader, writer)
|
||||
private readonly ILogger _logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public RoomPropertiesOperation(RagonBuffer reader, RagonBuffer writer) : base(reader, writer)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Handle(RagonContext context, NetworkChannel channel)
|
||||
{
|
||||
var player = context.RoomPlayer;
|
||||
if (context.ConnectionStatus == ConnectionStatus.Unauthorized)
|
||||
{
|
||||
_logger.Warn($"Player {context.Connection.Id} not authorized for this request");
|
||||
return;
|
||||
}
|
||||
|
||||
var roomData = Reader.ReadBytes(Reader.Capacity);
|
||||
|
||||
var room = context.Room;
|
||||
|
||||
var data = Reader.RawData;
|
||||
var dataSize = data.Length - 1;
|
||||
var headerSize = 3;
|
||||
var size = headerSize + dataSize;
|
||||
var sendData = new byte[size];
|
||||
var peerId = player.Connection.Id;
|
||||
|
||||
sendData[0] = (byte)RagonOperation.REPLICATE_RAW_DATA;
|
||||
sendData[1] = (byte)peerId;
|
||||
sendData[2] = (byte)(peerId >> 8);
|
||||
|
||||
Array.Copy(data, 1, sendData, headerSize, dataSize);
|
||||
|
||||
room.Broadcast(sendData, channel);
|
||||
if (room != null)
|
||||
room.UserData.Data = roomData;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user