/// <summary>
 /// Maneja el resultado de una prohibición de un jugador por parte del administrador
 /// </summary>
 /// <param name="result"></param>
 public void GetBanResult(BanResult result)
 {
     if (result == BanResult.PLAYER_BANNED)
     {
         MessageBox.Show(Resources.PlayerBannedMessage);
     }
     else
     {
         if (result == BanResult.PLAYER_ALREADY_BANNED)
         {
             MessageBox.Show(Resources.PlayerAlreadyBannedErrorMessage);
         }
         else
         {
             if (result == BanResult.ERROR_BANNING)
             {
                 MessageBox.Show(Resources.UnableToBanErrorMessage);
             }
             else
             {
                 MessageBox.Show(Resources.NoConnectionMessage);
             }
         }
     }
 }
 public void GetBanResult(BanResult result)
 {
     if (result == BanResult.PLAYER_BANNED)
     {
         banResult = BanResult.PLAYER_BANNED;
     }
     else
     {
         if (result == BanResult.PLAYER_ALREADY_BANNED)
         {
             banResult = BanResult.PLAYER_ALREADY_BANNED;
         }
         else
         {
             banResult = BanResult.ERROR_BANNING;
         }
     }
 }
예제 #3
0
        public static BanResult Ban(int n4NexonSN)
        {
            BanResult banResult = new BanResult();
            Default   @default  = Authenticator.CreateClientFromSN(n4NexonSN);
            int       num       = 0;

            if (@default == null)
            {
                banResult.nErrorCode      = 20024;
                banResult.strErrorMessage = "invalide nexon sn." + Environment.NewLine + "nNexonSN : " + n4NexonSN.ToString();
                return(banResult);
            }
            for (;;)
            {
                try
                {
                    BanResult banResult2 = @default.Ban((long)n4NexonSN);
                    banResult.nErrorCode      = banResult2.nErrorCode;
                    banResult.strErrorMessage = banResult2.strErrorMessage;
                }
                catch (Exception ex)
                {
                    if (num < Config.Authenticator.Soap.RetryCount)
                    {
                        num++;
                        if (num == Config.Authenticator.Soap.RetryCount)
                        {
                            @default.Timeout = Config.Authenticator.Soap.LongTimeout;
                        }
                        continue;
                    }
                    banResult.nErrorCode      = 20023;
                    banResult.strErrorMessage = "A unknown exception occured while calling a soap method." + Environment.NewLine + ex.ToString();
                    ErrorLogger.WriteLog(ErrorCode.SoapCallFailed, banResult.strErrorMessage, ex.StackTrace, string.Empty, "NexonSN: " + n4NexonSN.ToString());
                }
                finally
                {
                    @default.Dispose();
                }
                break;
            }
            return(banResult);
        }
예제 #4
0
        public void GetBanResult_ReturnERRORBANNING_BANNINGResult()
        {
            try
            {
                var baseAddress = new Uri("net.tcp://localhost:8090/Contratos");
                serviceHost = new ServiceHost(typeof(Contratos.MainService), baseAddress);
                System.ServiceModel.Channels.Binding binding = new NetTcpBinding();
                var address  = new EndpointAddress("net.tcp://localhost:8090/ServerTests");
                var endpoint = serviceHost
                               .AddServiceEndpoint(typeof(Contratos.IBanManager), binding, address.Uri);

                var smb = new ServiceMetadataBehavior {
                    HttpGetEnabled = false
                };
                serviceHost.Description.Behaviors.Add(smb);
                InstanceContext instanceContext = new InstanceContext(new BanCallbackHandler());
                banClient     = new BanManagerClient(instanceContext);
                endpoint.Name = banClient.Endpoint.Name;

                serviceHost.Open();
                serviceHost.Close();

                banClient.BanPlayer("testNickname");

                BanCallbackHandler banHandler = new BanCallbackHandler();
                BanResult          result     = banHandler.banResult;

                Assert.AreEqual(result, BanResult.ERROR_BANNING);
            }
            catch (EndpointNotFoundException)
            {
                banClient.Abort();
            }
            catch (CommunicationException)
            {
                banClient.Abort();
            }
        }