40 lines
778 B
C#
40 lines
778 B
C#
using NLog;
|
|
|
|
namespace ChatRoom;
|
|
|
|
public class ChatRoomLogic
|
|
{
|
|
private Thread thread;
|
|
private ChatRoomState state = new ChatRoomState();
|
|
private Logger log = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
public ChatRoomLogic()
|
|
{
|
|
thread = new Thread(BackgroundTask);
|
|
thread.Start();
|
|
}
|
|
|
|
public int RegisterClient(string name)
|
|
{
|
|
lock (state.accessLock)
|
|
{
|
|
int clientId = state.lastUniqueId;
|
|
state.clients.Add(new Client{
|
|
id = clientId,
|
|
name = name
|
|
});
|
|
log.Info($"Registered with client '{name}' with id {clientId}");
|
|
return clientId;
|
|
}
|
|
}
|
|
|
|
public void BackgroundTask()
|
|
{
|
|
while (true)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|