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.
47 lines
No EOL
1.2 KiB
C#
47 lines
No EOL
1.2 KiB
C#
using System.Net.Sockets;
|
|
using System.Text;
|
|
using WinPC.Engine.Abstract.Core;
|
|
using WinPC.Engine.Commands;
|
|
using WinPC.Engine.Directors;
|
|
|
|
namespace WinPC.Engine.States
|
|
{
|
|
public class MainMenuState : IState
|
|
{
|
|
|
|
public ServerDirector Director { get; private set; }
|
|
private Socket Connection { get; set; }
|
|
private ASCIIEncoding Encoding { get; set; }
|
|
private int Index;
|
|
|
|
public MainMenuState(ServerDirector director)
|
|
{
|
|
Director = director;
|
|
Encoding = new ASCIIEncoding();
|
|
|
|
}
|
|
public void Render(int index)
|
|
{
|
|
Index = index;
|
|
|
|
Connection = Director.ConnectedPlayers[index].Connection;
|
|
|
|
Director.ConnectedPlayers[index].Connection.Send(Encoding.GetBytes("Your now in the Main Menu State Welcome!! !"+"\n\r"));
|
|
|
|
|
|
|
|
}
|
|
|
|
public ICommand GetCommand()
|
|
{
|
|
|
|
var input = Director.RecieveInput(Index);
|
|
|
|
if(input == "connect")
|
|
{
|
|
return new SwitchStateCommand(Director, new ConnectState(Director),Index);
|
|
}
|
|
return new InvalidCommand(Connection);
|
|
}
|
|
}
|
|
} |