feat: room properties ready, player properties wip

This commit is contained in:
2024-05-07 22:42:45 +03:00
parent 6886808132
commit 5bf1881f81
22 changed files with 325 additions and 157 deletions
@@ -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);
}
}