39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using MauMau_Server.Websockets;
|
|
|
|
namespace MauMau_Server.Room;
|
|
|
|
public class RoomMessage
|
|
{
|
|
public string CurrentRoomType;
|
|
public string? MessageType;
|
|
public List<string> JoinedPlayers;
|
|
public string? Message;
|
|
|
|
public RoomMessage(string currentRoomType, IEnumerable<ConnectionInstance> joinedPlayers, string? message)
|
|
{
|
|
CurrentRoomType = currentRoomType;
|
|
JoinedPlayers = GetNamesFromConnections(joinedPlayers);
|
|
Message = message;
|
|
}
|
|
|
|
public RoomMessage(string currentRoomType, MessageType messageType, IEnumerable<ConnectionInstance> joinedPlayers, string? message)
|
|
{
|
|
CurrentRoomType = currentRoomType;
|
|
MessageType = messageType.ToString();
|
|
JoinedPlayers = GetNamesFromConnections(joinedPlayers);
|
|
Message = message;
|
|
}
|
|
|
|
private static List<string> GetNamesFromConnections(IEnumerable<ConnectionInstance> connections)
|
|
{
|
|
return connections.Select(player => player.Name).ToList();
|
|
}
|
|
}
|
|
|
|
public enum MessageType
|
|
{
|
|
INFO,
|
|
SUCCES,
|
|
WARNING,
|
|
ERROR
|
|
} |