ServerDirector.GetPlayer() helper method added for getting a player from the server without providing access to the servers collection libraries. ConnectState.Render() has some test code used when writing ServerDirector.GetPlayer() Started converting ConnectedPlayer and ConnectedThread collections to a single Dictionary collection. Not migrating everything to it until helper methods are finished.
38 lines
No EOL
890 B
C#
38 lines
No EOL
890 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 = new List<byte>();
|
|
|
|
public string Name { get; set; }
|
|
|
|
public Player(IState initialState, Socket connection)
|
|
{
|
|
Connection = connection;
|
|
CurrentState = initialState;
|
|
Name = "Player";
|
|
}
|
|
|
|
public void Disconnect()
|
|
{
|
|
Connection.Close();
|
|
}
|
|
|
|
public void SwitchState(IState state)
|
|
{
|
|
CurrentState = state;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return this.Name;
|
|
}
|
|
}
|
|
} |