feat(wip): Room Property and Player Property
This commit is contained in:
@@ -29,12 +29,14 @@ public sealed class AuthorizationOperation: BaseOperation
|
||||
private readonly RagonWebHookPlugin _webhook;
|
||||
private readonly RagonContextObserver _observer;
|
||||
private readonly RagonBuffer _writer;
|
||||
private readonly RagonServerConfiguration _configuration;
|
||||
|
||||
public AuthorizationOperation(
|
||||
RagonBuffer reader,
|
||||
RagonBuffer writer,
|
||||
RagonWebHookPlugin webhook,
|
||||
RagonContextObserver observer): base(reader, writer)
|
||||
RagonContextObserver observer,
|
||||
RagonServerConfiguration configuration): base(reader, writer)
|
||||
{
|
||||
_webhook = webhook;
|
||||
_observer = observer;
|
||||
@@ -55,7 +57,7 @@ public sealed class AuthorizationOperation: BaseOperation
|
||||
return;
|
||||
}
|
||||
|
||||
var configuration = context.Configuration;
|
||||
var configuration = _configuration;
|
||||
var key = Reader.ReadString();
|
||||
var name = Reader.ReadString();
|
||||
var payload = Reader.ReadString();
|
||||
|
||||
@@ -44,7 +44,7 @@ public sealed class EntityCreateOperation : BaseOperation
|
||||
Authority = eventAuthority,
|
||||
AttachId = attachId,
|
||||
StaticId = 0,
|
||||
BufferedEvents = context.Configuration.LimitBufferedEvents,
|
||||
BufferedEvents = context.LimitBufferedEvents,
|
||||
};
|
||||
|
||||
var entity = new RagonEntity(entityParameters);
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
using NLog;
|
||||
using Ragon.Protocol;
|
||||
using Ragon.Server.IO;
|
||||
using Ragon.Server.Lobby;
|
||||
|
||||
namespace Ragon.Server.Handler
|
||||
{
|
||||
|
||||
public class PlayerDataOperation : BaseOperation
|
||||
{
|
||||
private readonly ILogger _logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public PlayerDataOperation(RagonBuffer reader, RagonBuffer writer) : base(reader, writer)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Handle(RagonContext context, NetworkChannel channel)
|
||||
{
|
||||
if (context.ConnectionStatus == ConnectionStatus.Unauthorized)
|
||||
{
|
||||
_logger.Warn($"Player {context.Connection.Id} not authorized for this request");
|
||||
return;
|
||||
}
|
||||
|
||||
var playerDataLen = Reader.ReadUShort();
|
||||
var playerData = Reader.ReadBytes(playerDataLen);
|
||||
var player = context.RoomPlayer;
|
||||
|
||||
// player.SetData(playerData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2023 Eduard Kargin <kargin.eduard@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using NLog;
|
||||
using Ragon.Protocol;
|
||||
using Ragon.Server.IO;
|
||||
|
||||
namespace Ragon.Server.Handler;
|
||||
|
||||
public sealed class RoomRawDataOperation : BaseOperation
|
||||
{
|
||||
public RoomRawDataOperation(RagonBuffer reader, RagonBuffer writer) : base(reader, writer)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Handle(RagonContext context, NetworkChannel channel)
|
||||
{
|
||||
var player = context.RoomPlayer;
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public sealed class SceneLoadedOperation : BaseOperation
|
||||
Authority = eventAuthority,
|
||||
AttachId = 0,
|
||||
StaticId = staticId,
|
||||
BufferedEvents = context.Configuration.LimitBufferedEvents,
|
||||
BufferedEvents = context.LimitBufferedEvents,
|
||||
};
|
||||
|
||||
var entity = new RagonEntity(entityParameters);
|
||||
|
||||
Reference in New Issue
Block a user