public void TestGetToken()
        {
            TokenMultiRequest req = new TokenMultiRequest()
            {
                PAN      = this.testPan,
                ExpMonth = this.testExpMonth,
                ExpYear  = this.testExpYear
            };

            RPGClient          client   = new RPGClient(this.config.AppSettings.Settings["PrivateToken"].Value, this.uri);
            TokenMultiResponse response = client.TokenMulti.CreateAsync(req).Result;

            Assert.IsNotNull(response.Token);
            Assert.IsFalse(String.IsNullOrEmpty(response.Token.Token));

            TokenMultiResponse tokenResponse = client.TokenMulti.GetAsync(response.Token.Token).Result;

            Assert.AreEqual((int)HttpStatusCode.OK, tokenResponse.StatusCode);
            Assert.IsNotNull(tokenResponse.Token);
            Assert.AreEqual(response.Token.Token, tokenResponse.Token.Token);

            tokenResponse = client.TokenMulti.GetAsync("InvalidToken").Result;
            Assert.AreEqual((int)HttpStatusCode.BadRequest, tokenResponse.StatusCode);

            tokenResponse = client.TokenMulti.GetAsync("tm_invalidtoken").Result;
            Assert.AreEqual((int)HttpStatusCode.NotFound, tokenResponse.StatusCode);

            client        = new RPGClient("InvalidKey", this.uri);
            tokenResponse = client.TokenMulti.CreateAsync(req).Result;
            Assert.AreEqual((int)HttpStatusCode.Unauthorized, tokenResponse.StatusCode);
        }
Esempio n. 2
0
 public virtual void Init(RPGClient client)
 {
     this.client = client;
     this.gamePanel.Init(client);
     this.client.GameClient.OnDisconnected += GameClient_OnDisconnected;
     this.gamePanel.do_login();
 }
Esempio n. 3
0
        public void TestCreatePayment()
        {
            PaymentRequest req = new PaymentRequest()
            {
                PaymentMethod = new PaymentRequestMethod()
                {
                    PaymentType = PaymentTypes.Card,
                    PAN         = "4242424242424242",
                    ExpMonth    = "01",
                    ExpYear     = "20",
                    CVC2        = "000"
                },
                Amount          = 100,
                Currency        = "352",
                OrderId         = "TEST00000001",
                TransactionDate = DateTime.Now,
                TransactionType = TransactionTypes.Sale
            };

            RPGClient client = new RPGClient("myKey", "http://www.borgun.is/", new HttpMessageHandlerMock());
            PaymentTransactionResponse response = client.Payment.CreateAsync(req).Result;

            Assert.AreEqual((int)HttpStatusCode.Created, response.StatusCode);
            Assert.IsFalse(String.IsNullOrEmpty(response.Uri));
            Assert.IsNotNull(response.Transaction);
            Assert.AreEqual("TestTransaction", response.Transaction.TransactionId);
        }
Esempio n. 4
0
 public FormRoles(RPGClient client)
 {
     this.client = client;
     InitializeComponent();
     this.DialogResult = DialogResult.Ignore;
     init_role_templates();
 }
        public void TestCapture()
        {
            PaymentRequest req = new PaymentRequest()
            {
                TransactionType = TransactionTypes.PreAuthorization,
                PaymentMethod   = new PaymentRequestMethod()
                {
                    PaymentType = PaymentTypes.Card,
                    PAN         = this.testPan,
                    ExpMonth    = this.testExpMonth,
                    ExpYear     = this.testExpYear
                },
                Amount          = 100,
                Currency        = "352",
                OrderId         = "IntegrTest01",
                TransactionDate = DateTime.Now
            };

            RPGClient client = new RPGClient(this.config.AppSettings.Settings["PrivateToken"].Value, this.uri);
            PaymentTransactionResponse response = client.Payment.CreateAsync(req).Result;

            Assert.AreEqual((int)HttpStatusCode.Created, response.StatusCode);

            PaymentCaptureResponse captureResponse = client.Payment.CaptureAsync(response.Transaction.TransactionId).Result;

            Assert.AreEqual(200, captureResponse.StatusCode);

            captureResponse = client.Payment.CaptureAsync(response.Transaction.TransactionId).Result;
            Assert.AreEqual(400, captureResponse.StatusCode);
        }
        public void TestDisableToken()
        {
            TokenSingleRequest req = new TokenSingleRequest()
            {
                PAN           = this.testPan,
                ExpMonth      = this.testExpMonth,
                ExpYear       = this.testExpYear,
                TokenLifetime = 20
            };

            RPGClient           client   = new RPGClient(this.config.AppSettings.Settings["PrivateToken"].Value, this.uri);
            TokenSingleResponse response = client.TokenSingle.CreateAsync(req).Result;

            Assert.IsNotNull(response.Token);
            Assert.IsFalse(String.IsNullOrEmpty(response.Token.Token));

            TokenSingleResponse tokenResponse = client.TokenSingle.DisableAsync(response.Token.Token).Result;

            Assert.AreEqual((int)HttpStatusCode.NoContent, tokenResponse.StatusCode);
            tokenResponse = client.TokenSingle.GetAsync(response.Token.Token).Result;
            Assert.AreEqual(response.Token.Token, tokenResponse.Token.Token);
            Assert.IsFalse(tokenResponse.Token.Enabled);

            tokenResponse = client.TokenSingle.DisableAsync("InvalidToken").Result;
            Assert.AreEqual((int)HttpStatusCode.BadRequest, tokenResponse.StatusCode);

            tokenResponse = client.TokenSingle.DisableAsync("ts_invalidtoken").Result;
            Assert.AreEqual((int)HttpStatusCode.NotFound, tokenResponse.StatusCode);
        }
Esempio n. 7
0
 public FormChat(RPGClient client)
 {
     this.client = client;
     InitializeComponent();
     this.comboBox1.Text      = "world";
     richTextBox.LinkClicked += OnClickLink;
     this.client.GameClient.Listen <ClientChatNotify>(OnChatNotify);
 }
        public void TestDisable()
        {
            RPGClient           client   = new RPGClient("myKey", "http://www.borgun.is/", new HttpMessageHandlerMock());
            TokenSingleResponse response = client.TokenSingle.DisableAsync("testtoken").Result;

            Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode);
            Assert.IsNull(response.Token);
        }
Esempio n. 9
0
 public FormLoginQueue(RPGClient client, Protocol.Client.ClientEnterGateResponse rsp)
 {
     InitializeComponent();
     this.client = client;
     this.client.OnGateQueueUpdated += Client_OnGateQueueUpdated;
     this.server      = RPGClientTemplateManager.Instance.GetServer(client.last_EnterGateRequest.c2s_serverID);
     this.label1.Text = $"【{server?.name}】服务器人数已满,目前排位在{rsp.s2c_queueCount + 1},预计等待时间{rsp.s2c_queuetTime}。";
 }
Esempio n. 10
0
        public void TestCaptureTransaction()
        {
            RPGClient client = new RPGClient("myKey", "http://www.borgun.is/", new HttpMessageHandlerMock());
            PaymentCaptureResponse response = client.Payment.CaptureAsync("TestTransaction").Result;

            Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode);
            Assert.IsNotNull(response.Result);
            Assert.AreEqual("TestTransaction", response.Result.TransactionId);
        }
        public void TestGet()
        {
            RPGClient          client   = new RPGClient("myKey", "http://www.borgun.is/", new HttpMessageHandlerMock());
            TokenMultiResponse response = client.TokenMulti.GetAsync("testtoken").Result;

            Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode);
            Assert.IsNotNull(response.Token);
            Assert.AreEqual("TestTokenMulti", response.Token.Token);
        }
Esempio n. 12
0
        public virtual BotRunner CreateBotRunner(BotConfig cfg, AddBotConfig add, string account)
        {
            var c = new RPGClient(this.DataFactory.MessageCodec, new ClientInfo()
            {
                sdkName = "OneGame"
            });

            return(new BotRunner(c, cfg, add, account));
        }
Esempio n. 13
0
 public FormLogin(RPGClient client)
 {
     this.client = client;
     this.client.OnGateEntered += Client_OnGateEntered;
     InitializeComponent();
     DeepCore.Properties.LoadStaticFieldsFromFile(new System.IO.FileInfo(save_file), typeof(FormLoginSave));
     this.txt_Password.Text = FormLoginSave.password;
     if (FormLoginSave.ipaddress != null)
     {
         for (int i = 0; i < FormLoginSave.ipaddress.Length; i++)
         {
             if (i == 0)
             {
                 this.txt_Server.Text = FormLoginSave.ipaddress[0];
             }
             else if (!this.txt_Server.Items.Contains(FormLoginSave.ipaddress[i]))
             {
                 this.txt_Server.Items.Add(FormLoginSave.ipaddress[i]);
             }
         }
     }
     if (FormLoginSave.accounts != null)
     {
         for (int i = 0; i < FormLoginSave.accounts.Length; i++)
         {
             if (i == 0)
             {
                 this.txt_Account.Text = FormLoginSave.accounts[0];
             }
             else if (!this.txt_Account.Items.Contains(FormLoginSave.accounts[i]))
             {
                 this.txt_Account.Items.Add(FormLoginSave.accounts[i]);
             }
         }
     }
     if (FormLoginSave.serverID != null)
     {
         for (int i = 0; i < FormLoginSave.serverID.Length; i++)
         {
             if (i == 0)
             {
                 this.txt_ServerID.Text = FormLoginSave.serverID[0];
             }
             else if (!this.txt_ServerID.Items.Contains(FormLoginSave.serverID[i]))
             {
                 this.txt_ServerID.Items.Add(FormLoginSave.serverID[i]);
             }
         }
     }
     foreach (var server in RPGClientTemplateManager.Instance.GetAllServers())
     {
         this.com_ServerInfo.Items.Add(server);
     }
     this.DialogResult = DialogResult.Ignore;
 }
        public void TestCreate()
        {
            TokenMultiRequest req = new TokenMultiRequest()
            {
                PAN      = "4242424242424242",
                ExpMonth = "01",
                ExpYear  = "20"
            };

            RPGClient          client   = new RPGClient("myKey", "http://www.borgun.is/", new HttpMessageHandlerMock());
            TokenMultiResponse response = client.TokenMulti.CreateAsync(req).Result;

            Assert.AreEqual((int)HttpStatusCode.Created, response.StatusCode);
            Assert.IsFalse(String.IsNullOrEmpty(response.Uri));
            Assert.IsNotNull(response.Token);
            Assert.AreEqual("TestTokenMulti", response.Token.Token);
        }
Esempio n. 15
0
        public void Init(RPGClient client)
        {
            this.Client = client;
            this.Client.OnZoneChanged      += Client_OnZoneChanged;
            this.Client.OnZoneLeaved       += Client_OnZoneLeaved;
            this.Client.OnGameDisconnected += Client_OnGameDisconnected1;
            this.Client.OnError            += Client_OnError;

            this.SessionView = new FormSessionTracer(this);
            this.SessionView.ShowInTaskbar = false;
            this.SessionView.FormClosing  += (object sender, FormClosingEventArgs e) =>
            {
                if (this.Visible)
                {
                    e.Cancel = true;
                    SessionView.Hide();
                }
            };
        }
        public void TestCreateToken()
        {
            TokenSingleRequest req = new TokenSingleRequest()
            {
                PAN           = this.testPan,
                ExpMonth      = this.testExpMonth,
                ExpYear       = this.testExpYear,
                TokenLifetime = 20
            };

            RPGClient           client   = new RPGClient(this.config.AppSettings.Settings["PrivateToken"].Value, this.uri);
            TokenSingleResponse response = client.TokenSingle.CreateAsync(req).Result;

            Assert.AreEqual((int)HttpStatusCode.Created, response.StatusCode);
            Assert.IsFalse(String.IsNullOrEmpty(response.Uri));
            Assert.IsNotNull(response.Token);
            Assert.IsTrue(!String.IsNullOrEmpty(response.Token.Token));
            Assert.AreEqual(this.uri + "api/token/single/" + response.Token.Token, response.Uri);

            req.PAN  = "1234567890123456";
            response = client.TokenSingle.CreateAsync(req).Result;
            Assert.AreEqual((int)HttpStatusCode.BadRequest, response.StatusCode);
            Assert.IsNull(response.Token);
            Assert.IsFalse(String.IsNullOrEmpty(response.Message));
            Assert.AreEqual("{\"Message\":\"PAN: InvalidFormat\"}", response.Message);

            req.PAN           = null;
            req.ExpMonth      = null;
            req.ExpYear       = null;
            req.TokenLifetime = 0;

            response = client.TokenSingle.CreateAsync(req).Result;
            Assert.AreEqual((int)HttpStatusCode.BadRequest, response.StatusCode);
            Assert.IsNull(response.Token);
            Assert.IsFalse(String.IsNullOrEmpty(response.Message));
            Assert.AreEqual("{\"Message\":\"PAN: InvalidFormat; ExpMonth: Invalid expiration date; TokenLifetime: 'Token Lifetime' must be greater than '0'.\"}", response.Message);

            client   = new RPGClient("InvalidKey", this.uri);
            response = client.TokenSingle.CreateAsync(req).Result;
            Assert.AreEqual((int)HttpStatusCode.Unauthorized, response.StatusCode);
        }
Esempio n. 17
0
 public BotRunner(RPGClient c, BotConfig cfg, AddBotConfig add, string account)
 {
     this.log     = new ListLogger("bot[" + account + "]-");
     this.cfg     = cfg;
     this.add     = add;
     this.account = account;
     this.client  = c;
     this.client.OnGateEntered += on_gate_connect_callback;
     this.client.GateClient.Listen <ClientEnterGateInQueueNotify>(on_gate_in_queue);
     foreach (var type in BotFactory.Instance.GetModuleTypes())
     {
         var m = ReflectionUtil.CreateInterface <BotModule>(type, this);
         modules.Add(m.GetType(), m);
     }
     client.AddTimePeriodicMS(10000, (e) =>
     {
         if (client.CurrentZoneLayer != null && client.GameClient != null && client.GameClient.IsHandshake)
         {
             client.GameClient.Request <ClientPong>(new ClientPing(), (s, a) => { });
         }
     });
 }
Esempio n. 18
0
        public void TestCreatePayment()
        {
            PaymentRequest req = new PaymentRequest()
            {
                TransactionType = TransactionTypes.PreAuthorization,
                PaymentMethod   = new PaymentRequestMethod()
                {
                    PaymentType = PaymentTypes.Card,
                    PAN         = this.testPan,
                    ExpMonth    = this.testExpMonth,
                    ExpYear     = this.testExpYear
                },
                Amount          = 100,
                Currency        = "352",
                OrderId         = "IntegrTest01",
                TransactionDate = DateTime.Now
            };

            RPGClient client = new RPGClient(this.config.AppSettings.Settings["PrivateToken"].Value, this.uri);
            PaymentTransactionResponse response = client.Payment.CreateAsync(req).Result;

            Assert.AreEqual((int)HttpStatusCode.Created, response.StatusCode);
            Assert.AreEqual(this.uri + "api/payment/" + response.Transaction.TransactionId, response.Uri);
            Assert.AreEqual("000", response.Transaction.ActionCode);
            Assert.AreEqual(TransactionStatus.Uncaptured, response.Transaction.TransactionStatus);
            Assert.AreEqual(TransactionTypes.PreAuthorization, response.Transaction.TransactionType);

            req      = new PaymentRequest();
            response = client.Payment.CreateAsync(req).Result;
            Assert.AreEqual((int)HttpStatusCode.BadRequest, response.StatusCode);
            Assert.IsFalse(String.IsNullOrEmpty(response.Message));

            client   = new RPGClient("InvalidKey", this.uri);
            response = client.Payment.CreateAsync(req).Result;
            Assert.AreEqual((int)HttpStatusCode.Unauthorized, response.StatusCode);
        }
Esempio n. 19
0
 public FormStore(RPGClient client)
 {
     this.mClient = client;
     InitializeComponent();
 }
Esempio n. 20
0
 public FormMail(RPGClient client)
 {
     InitializeComponent();
     this.client = client;
     AddListener();
 }
Esempio n. 21
0
 public FormWriteMail(RPGClient client)
 {
     InitializeComponent();
     this.client = client;
 }