feat(wip): list rooms
This commit is contained in:
@@ -1,13 +1,12 @@
|
|||||||
using Ragon.Protocol;
|
namespace Ragon.Client
|
||||||
|
|
||||||
namespace Ragon.Client;
|
|
||||||
|
|
||||||
public struct RagonRoomInformation
|
|
||||||
{
|
{
|
||||||
|
public struct RagonRoomInformation
|
||||||
|
{
|
||||||
public string Id;
|
public string Id;
|
||||||
public string Scene;
|
public string Scene;
|
||||||
public int PlayerMax;
|
public int PlayerMax;
|
||||||
public int PlayerMin;
|
public int PlayerMin;
|
||||||
public int PlayerCount;
|
public int PlayerCount;
|
||||||
public Dictionary<string, byte[]> Properties;
|
public Dictionary<string, byte[]> Properties;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -31,11 +31,11 @@ namespace Ragon.Client
|
|||||||
|
|
||||||
public void CreateOrJoin(string sceneName, int minPlayers, int maxPlayers)
|
public void CreateOrJoin(string sceneName, int minPlayers, int maxPlayers)
|
||||||
{
|
{
|
||||||
var parameters = new RagonRoomParameters() {Scene = sceneName, Min = minPlayers, Max = maxPlayers};
|
var parameters = new RagonRoomPayload() {Scene = sceneName, Min = minPlayers, Max = maxPlayers};
|
||||||
CreateOrJoin(parameters);
|
CreateOrJoin(parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateOrJoin(RagonRoomParameters parameters)
|
public void CreateOrJoin(RagonRoomPayload parameters)
|
||||||
{
|
{
|
||||||
_buffer.Clear();
|
_buffer.Clear();
|
||||||
_buffer.WriteOperation(RagonOperation.JOIN_OR_CREATE_ROOM);
|
_buffer.WriteOperation(RagonOperation.JOIN_OR_CREATE_ROOM);
|
||||||
@@ -48,15 +48,15 @@ namespace Ragon.Client
|
|||||||
|
|
||||||
public void Create(string sceneName, int minPlayers, int maxPlayers)
|
public void Create(string sceneName, int minPlayers, int maxPlayers)
|
||||||
{
|
{
|
||||||
Create(null, new RagonRoomParameters() {Scene = sceneName, Min = minPlayers, Max = maxPlayers});
|
Create(null, new RagonRoomPayload() {Scene = sceneName, Min = minPlayers, Max = maxPlayers});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Create(string roomId, string sceneName, int minPlayers, int maxPlayers)
|
public void Create(string roomId, string sceneName, int minPlayers, int maxPlayers)
|
||||||
{
|
{
|
||||||
Create(roomId, new RagonRoomParameters() {Scene = sceneName, Min = minPlayers, Max = maxPlayers});
|
Create(roomId, new RagonRoomPayload() {Scene = sceneName, Min = minPlayers, Max = maxPlayers});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Create(string roomId, RagonRoomParameters parameters)
|
public void Create(string roomId, RagonRoomPayload parameters)
|
||||||
{
|
{
|
||||||
_buffer.Clear();
|
_buffer.Clear();
|
||||||
_buffer.WriteOperation(RagonOperation.CREATE_ROOM);
|
_buffer.WriteOperation(RagonOperation.CREATE_ROOM);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
namespace Ragon.Protocol
|
namespace Ragon.Protocol
|
||||||
{
|
{
|
||||||
public class RagonRoomParameters: IRagonSerializable
|
public class RagonRoomPayload: IRagonSerializable
|
||||||
{
|
{
|
||||||
public string Scene { get; set; }
|
public string Scene { get; set; }
|
||||||
public int Min { get; set; }
|
public int Min { get; set; }
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Ragon.Server.Handler;
|
|||||||
|
|
||||||
public sealed class RoomCreateOperation : BaseOperation
|
public sealed class RoomCreateOperation : BaseOperation
|
||||||
{
|
{
|
||||||
private readonly RagonRoomParameters _roomParameters = new();
|
private readonly RagonRoomPayload _roomPayload = new();
|
||||||
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||||
private readonly IServerPlugin _serverPlugin;
|
private readonly IServerPlugin _serverPlugin;
|
||||||
private readonly RagonWebHookPlugin _ragonWebHookPlugin;
|
private readonly RagonWebHookPlugin _ragonWebHookPlugin;
|
||||||
@@ -65,13 +65,13 @@ public sealed class RoomCreateOperation : BaseOperation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_roomParameters.Deserialize(Reader);
|
_roomPayload.Deserialize(Reader);
|
||||||
|
|
||||||
var information = new RoomInformation()
|
var information = new RoomInformation()
|
||||||
{
|
{
|
||||||
Scene = _roomParameters.Scene,
|
Scene = _roomPayload.Scene,
|
||||||
Max = _roomParameters.Max,
|
Max = _roomPayload.Max,
|
||||||
Min = _roomParameters.Min,
|
Min = _roomPayload.Min,
|
||||||
};
|
};
|
||||||
|
|
||||||
var lobbyPlayer = context.LobbyPlayer;
|
var lobbyPlayer = context.LobbyPlayer;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Ragon.Server.Handler;
|
|||||||
|
|
||||||
public sealed class RoomJoinOrCreateOperation : BaseOperation
|
public sealed class RoomJoinOrCreateOperation : BaseOperation
|
||||||
{
|
{
|
||||||
private readonly RagonRoomParameters _roomParameters = new();
|
private readonly RagonRoomPayload _roomPayload = new();
|
||||||
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||||
private readonly IServerPlugin _serverPlugin;
|
private readonly IServerPlugin _serverPlugin;
|
||||||
private readonly RagonWebHookPlugin _ragonWebHookPlugin;
|
private readonly RagonWebHookPlugin _ragonWebHookPlugin;
|
||||||
@@ -48,9 +48,9 @@ public sealed class RoomJoinOrCreateOperation : BaseOperation
|
|||||||
var roomId = Guid.NewGuid().ToString();
|
var roomId = Guid.NewGuid().ToString();
|
||||||
var lobbyPlayer = context.LobbyPlayer;
|
var lobbyPlayer = context.LobbyPlayer;
|
||||||
|
|
||||||
_roomParameters.Deserialize(Reader);
|
_roomPayload.Deserialize(Reader);
|
||||||
|
|
||||||
if (context.Lobby.FindRoomByScene(_roomParameters.Scene, out var existsRoom))
|
if (context.Lobby.FindRoomByScene(_roomPayload.Scene, out var existsRoom))
|
||||||
{
|
{
|
||||||
var player = new RagonRoomPlayer(context.Connection, lobbyPlayer.Id, lobbyPlayer.Name);
|
var player = new RagonRoomPlayer(context.Connection, lobbyPlayer.Id, lobbyPlayer.Name);
|
||||||
|
|
||||||
@@ -67,9 +67,9 @@ public sealed class RoomJoinOrCreateOperation : BaseOperation
|
|||||||
{
|
{
|
||||||
var information = new RoomInformation()
|
var information = new RoomInformation()
|
||||||
{
|
{
|
||||||
Scene = _roomParameters.Scene,
|
Scene = _roomPayload.Scene,
|
||||||
Max = _roomParameters.Max,
|
Max = _roomPayload.Max,
|
||||||
Min = _roomParameters.Min,
|
Min = _roomPayload.Min,
|
||||||
};
|
};
|
||||||
|
|
||||||
var roomPlayer = new RagonRoomPlayer(context.Connection, lobbyPlayer.Id, lobbyPlayer.Name);
|
var roomPlayer = new RagonRoomPlayer(context.Connection, lobbyPlayer.Id, lobbyPlayer.Name);
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ namespace Ragon.Server.Logging;
|
|||||||
|
|
||||||
public interface IRagonLogger
|
public interface IRagonLogger
|
||||||
{
|
{
|
||||||
public void Warning(string tag, string message);
|
public void Warning(string message);
|
||||||
public void Info(string tag, string message);
|
public void Info(string message);
|
||||||
public void Error(string tag, string message);
|
public void Error(string message);
|
||||||
public void Trace(string tag, string message);
|
public void Error(Exception ex);
|
||||||
|
public void Trace(string message);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Ragon.Server.Logging;
|
||||||
|
|
||||||
|
public interface IRagonLoggerFactory
|
||||||
|
{
|
||||||
|
public IRagonLogger GetLogger(string tag);
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
namespace Ragon.Server.Logging
|
||||||
|
{
|
||||||
|
public class LoggerManager
|
||||||
|
{
|
||||||
|
private static IRagonLoggerFactory _factory;
|
||||||
|
|
||||||
|
public static void SetLoggerFactory(IRagonLoggerFactory loggerFactory)
|
||||||
|
{
|
||||||
|
_factory = loggerFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IRagonLogger GetLogger(string tag)
|
||||||
|
{
|
||||||
|
return _factory.GetLogger(tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user