Exemplo n.º 1
0
 //methods
 public void RiseEvent(Command command)
 {
     switch (command.CurrentCommand)
     {
         case "Move":
             MoveEvent(command.Data);
             break;
         case "Exit":
             ExitEvent();
             break;
         case "StartGame":
             StartGameEvent();
             break;
         case "YourStep":
             YourStepEvent(command.Data);
             break;
         case "OpponentStep":
             OpponentStepEvent(command.Data);
             break;
         case "Win":
             WinEvent();
             break;
         case "Lose":
             LoseEvent();
             break;
         case "Continue":
             ContinueEvent();
             break;
     }
 }
Exemplo n.º 2
0
 public void Exit()
 {
     Command command = new Command(Command.Commands.Exit, "");
     string message = protocol.ToMessage(command);
     messanger.SendMessage(clientThread.Client.Socket, message);
     clientThread.Stop();
 }
Exemplo n.º 3
0
        //methods
        public bool Login(IPEndPoint ipEndPoint, string name)
        {
            clientThread.Client.Connect(ipEndPoint);
            clientThread.Client.Name = name;

            Command command = new Command(Command.Commands.Connect, clientThread.Client.Name);
            string message = protocol.ToMessage(command);
            messanger.SendMessage(clientThread.Client.Socket, message);

            message = messanger.ReadMessage(clientThread.Client.Socket);
            command = protocol.ToCommand(message);

            return command.CurrentCommand == Command.Commands.Confirm.ToString();
        }
Exemplo n.º 4
0
 //method
 public void RiseEvent(Command command)
 {
     switch (command.CurrentCommand)
     {
         case "GetPlayers":
             GetPlayersEvent(command.Data);
             break;
         case "Invite":
             InviteEvent(command.Data);
             break;
         case "Confirm":
             ConfirmEvent();
             break;
         case "Reject":
             RejectEvent();
             break;
         case "StartGame":
             StartGameEvent(command.Data);
             break;
     }
 }
Exemplo n.º 5
0
 public string ToMessage(Command command)
 {
     return jsonParser.CommandToJson(command);
 }
Exemplo n.º 6
0
 public void SendInvite(string name)
 {
     Command command = new Command(Command.Commands.Invite, name);
     string message = protocol.ToMessage(command);
     messanger.SendMessage(clientThread.Client.Socket, message);
 }
Exemplo n.º 7
0
 //methods
 public string CommandToJson(Command command)
 {
     return JsonConvert.SerializeObject(command);
 }
Exemplo n.º 8
0
 internal void Move(int position)
 {
     Command command = new Command(Command.Commands.Move, position.ToString());
     string message = protocol.ToMessage(command);
     gameThread.Client.SendMessage(message);
 }