Exemplo n.º 1
0
 private void AuthorizePlayerCompleted(object sender, AuthorizePlayerCompletedEventArgs args)
 {
     EnterGameCompletedHandler handler = myEnterGameCompletedHandler;
       if (handler != null)
       {
     myEnterGameCompletedHandler = null;
     if (args.Error != null)
     {
       handler(false, args.Error.Message, null);
     }
     else
     {
       switch(args.Result)
       {
     case AuthorizePlayerResult.Ok:
       handler(true, null, args.players);
       break;
     case AuthorizePlayerResult.NoAuthorizationStarted:
       handler(false, "Ошибка коммуникации", null);
       break;
     case AuthorizePlayerResult.NoSuchGame:
       handler(false, "Нет такой игры", null);
       break;
     case AuthorizePlayerResult.NoSuchPlayer:
       handler(false, "Нет такого игрока", null);
       break;
     case AuthorizePlayerResult.WrongPassword:
       handler(false, "Пароль неверен", null);
       break;
     default:
       throw new ArgumentOutOfRangeException();
       }
     }
       }
 }
Exemplo n.º 2
0
 private void StartAuthorizePlayerCompleted(object sender, StartAuthorizePlayerCompletedEventArgs args)
 {
     if (myPassword != null)
       {
     if (args.Error != null)
     {
       EnterGameCompletedHandler handler = myEnterGameCompletedHandler;
       if (handler != null)
       {
     myEnterGameCompletedHandler = null;
     handler(false, args.Error.Message, null);
       }
       return;
     }
     string encryptedText = EncryptionUtil.EncryptStringToString(args.Result, myGamePassword);
     myProxy.AuthorizePlayerAsync(encryptedText, 0);
       }
 }
Exemplo n.º 3
0
 public void EnterGame(string gameName, string playerName, string gamePassword, EnterGameCompletedHandler completedHandler, Action startGameHandler)
 {
     myStartGameHandler = startGameHandler;
       myGamePassword = gamePassword;
       myEnterGameCompletedHandler = completedHandler;
       myProxy.StartAuthorizePlayerAsync(gameName, playerName);
 }