Partial rewrite, missing:
- Correctly parsing incoming messages - Sending the gamestate after relevant actions
This commit is contained in:
39
Room/Lobby.cs
Normal file
39
Room/Lobby.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using MauMau_Server.Mau;
|
||||
using MauMau_Server.Websockets;
|
||||
|
||||
namespace MauMau_Server.Room;
|
||||
|
||||
public class Lobby : RoomType
|
||||
{
|
||||
private readonly Room _room;
|
||||
|
||||
public Lobby(Room room)
|
||||
{
|
||||
_room = room;
|
||||
}
|
||||
|
||||
public Lobby(Room room, ConnectionInstance connection)
|
||||
{
|
||||
_room = room;
|
||||
Console.WriteLine(connection.Name + " won the game!");
|
||||
}
|
||||
|
||||
public void OnMessage(ConnectionInstance sender, string message)
|
||||
{
|
||||
// TODO: Add a way to change game settings
|
||||
if (sender == _room._host)
|
||||
{
|
||||
_room._roomType = new Game(_room, _room.Connections);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnConnect(ConnectionInstance connection)
|
||||
{
|
||||
var roomMessage = new RoomMessage("LOBBY", MessageType.INFO, _room.Connections, connection.Name + " joined!");
|
||||
}
|
||||
|
||||
public void OnDisconnect(ConnectionInstance connection)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user