Exemple #1
0
 public void Exit()
 {
     Command command = new Command(Command.Commands.Exit, "");
     string message = protocol.ToMessage(command);
     messanger.SendMessage(clientThread.Client.Socket, message);
     clientThread.Stop();
 }
Exemple #2
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;
     }
 }
Exemple #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();
        }
 //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;
     }
 }
Exemple #5
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);
 }
Exemple #6
0
 public string ToMessage(Command command)
 {
     return jsonParser.CommandToJson(command);
 }
Exemple #7
0
 public void Move(int position)
 {
     Command command = new Command(Command.Commands.Move, position.ToString());
     string message = protocol.ToMessage(command);
     gameThread.Client.SendMessage(message);
 }
Exemple #8
0
 //methods
 public string CommandToJson(Command command)
 {
     return JsonConvert.SerializeObject(command);
 }