muddesigner/MudEngine/WinPC.Engine/States/ConnectState.cs
Scionwest_cp 24c9fae4f5 * IPlayer - Connection and Buffer properties added along with SwitchState(IState) method
* 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.
2012-06-06 20:56:30 -07:00

47 lines
No EOL
1.3 KiB
C#

using System;
using System.Net.Sockets;
using System.Text;
using WinPC.Engine.Abstract.Core;
using WinPC.Engine.Commands;
using WinPC.Engine.Directors;
using WinPC.Engine.Core;
namespace WinPC.Engine.States
{
public class ConnectState : IState
{
public ServerDirector Director { get; private set; }
private Socket connection;
private ASCIIEncoding encoding;
private IPlayer player;
public ConnectState(ServerDirector director)
{
Director = director;
encoding = new ASCIIEncoding();
}
public void Render(IPlayer connectedPlayer)
{
connection = connectedPlayer.Connection;
player = connectedPlayer;
connection.Send(encoding.GetBytes("Welcome to Scionwest's Mud Engine!" + "\n\r"));
connection.Send(encoding.GetBytes("Please enter your name" + "\n\r"));
}
public ICommand GetCommand()
{
var input = Director.RecieveInput(player);
if (input == "menu")
{
return new SwitchStateCommand(Director, new MainMenuState(Director), player);
}
return new InvalidCommand(connection);
}
}
}