* Switched the ServerDirector over from using two List Collections to maintain Client Threads and Player instances into a single Dictionary. Required adjusting the majority of the existing Types, but should now be functional. Need to still add some safety checks for null references since we are now passing a reference Type around.
40 lines
No EOL
926 B
C#
40 lines
No EOL
926 B
C#
using System.Collections.Generic;
|
|
using System.Net.Sockets;
|
|
using WinPC.Engine.Abstract.Core;
|
|
|
|
namespace WinPC.Engine.Core
|
|
{
|
|
public class Player : IPlayer
|
|
{
|
|
public Socket Connection { get; private set; }
|
|
public IState CurrentState { get; private set; }
|
|
|
|
public List<byte> Buffer { get; set; }
|
|
|
|
public string Name { get; set; }
|
|
|
|
public Player(IState initialState, Socket connection)
|
|
{
|
|
Connection = connection;
|
|
CurrentState = initialState;
|
|
Name = "Player";
|
|
|
|
Buffer = new List<byte>();
|
|
}
|
|
|
|
public void Disconnect()
|
|
{
|
|
Connection.Close();
|
|
}
|
|
|
|
public void SwitchState(IState state)
|
|
{
|
|
CurrentState = state;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return this.Name;
|
|
}
|
|
}
|
|
} |