feat(wip) room properties
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using Ragon.Protocol;
|
||||
|
||||
namespace Ragon.Server.Data;
|
||||
|
||||
public class RagonData
|
||||
{
|
||||
private byte[] _data = Array.Empty<byte>();
|
||||
public bool IsDirty { get; set; }
|
||||
public byte[] Data
|
||||
{
|
||||
get => _data;
|
||||
set
|
||||
{
|
||||
_data = value;
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public RagonData(byte[] data)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
}
|
||||
@@ -86,6 +86,7 @@ public sealed class AuthorizationOperation: BaseOperation
|
||||
|
||||
var playerId = context.LobbyPlayer.Id;
|
||||
var playerName = context.LobbyPlayer.Name;
|
||||
|
||||
var playerPayload = context.LobbyPlayer.Payload;
|
||||
|
||||
_writer.Clear();
|
||||
|
||||
@@ -24,9 +24,20 @@ namespace Ragon.Server.Handler
|
||||
|
||||
var playerDataLen = Reader.ReadUShort();
|
||||
var playerData = Reader.ReadBytes(playerDataLen);
|
||||
var player = context.RoomPlayer;
|
||||
|
||||
// player.SetData(playerData);
|
||||
var roomPlayer = context.RoomPlayer;
|
||||
if (roomPlayer != null)
|
||||
{
|
||||
roomPlayer.UserData.Data = playerData;
|
||||
return;
|
||||
}
|
||||
|
||||
var lobbyPlayer = context.RoomPlayer;
|
||||
if (lobbyPlayer != null)
|
||||
{
|
||||
lobbyPlayer.UserData.Data = playerData;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using Ragon.Server.Data;
|
||||
using Ragon.Server.IO;
|
||||
|
||||
namespace Ragon.Server.Lobby;
|
||||
@@ -30,13 +31,14 @@ public class RagonLobbyPlayer
|
||||
public INetworkConnection Connection { get; }
|
||||
public string Id { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
public string Payload { get; private set; }
|
||||
|
||||
public RagonLobbyPlayer(INetworkConnection connection, string id, string name, string payload)
|
||||
public RagonData UserData { get; private set; }
|
||||
|
||||
public RagonLobbyPlayer(INetworkConnection connection, string id, string name, byte[] payload)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
Payload = payload;
|
||||
Connection = connection;
|
||||
UserData = new RagonData(payload);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using Ragon.Protocol;
|
||||
using Ragon.Server.Handler;
|
||||
@@ -58,7 +59,8 @@ public class RagonWebHookPlugin
|
||||
var authorizationResponse = JsonConvert.DeserializeObject<AuthorizationResponse>(content);
|
||||
if (authorizationResponse != null)
|
||||
{
|
||||
var lobbyPlayer = new RagonLobbyPlayer(context.Connection, authorizationResponse.Id, authorizationResponse.Name, authorizationResponse.Payload);
|
||||
var bytes = Encoding.UTF8.GetBytes(authorizationResponse.Payload);
|
||||
var lobbyPlayer = new RagonLobbyPlayer(context.Connection, authorizationResponse.Id, authorizationResponse.Name, bytes);
|
||||
|
||||
context.SetPlayer(lobbyPlayer);
|
||||
authorizationOperation.Approve(context);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using Ragon.Server.Data;
|
||||
using Ragon.Server.Entity;
|
||||
using Ragon.Server.IO;
|
||||
|
||||
@@ -29,12 +30,15 @@ public class RagonRoomPlayer
|
||||
public RagonRoom Room { get; private set; }
|
||||
public RagonEntityCache Entities { get; private set; }
|
||||
|
||||
public RagonData UserData { get; private set; }
|
||||
|
||||
public RagonRoomPlayer(INetworkConnection connection, string id, string name)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
Connection = connection;
|
||||
Entities = new RagonEntityCache();
|
||||
UserData = new RagonData(Array.Empty<byte>());
|
||||
}
|
||||
|
||||
public void AttachEntity(RagonEntity entity)
|
||||
|
||||
Reference in New Issue
Block a user