Beispiel #1
0
 public Client(Gs2.Unity.Util.Profile profile)
 {
     _profile = profile;
     _client  = new Gs2MoneyWebSocketClient(profile.Gs2Session);
     if (profile.checkRevokeCertificate)
     {
         _restClient = new Gs2MoneyRestClient(profile.Gs2RestSession);
     }
     else
     {
         _restClient = new Gs2MoneyRestClient(profile.Gs2RestSession, new DisabledCertificateHandler());
     }
 }
Beispiel #2
0
        public static IEnumerator Deposit(
            string identifierDepositClientId,
            string identifierDepositClientSecret,
            string moneyNamespaceName,
            string userId,
            int slot,
            float price,
            int value,
            DepositEvent onDeposit,
            ErrorEvent onError
            )
        {
            // このコードは実際にアプリケーションで使用するべきではありません。
            // アプリ内から課金通貨の残高を加算できるようにすることは、事業に多大な悪い影響を及ぼす可能性があります。
            var restSession = new Gs2RestSession(
                new BasicGs2Credential(
                    identifierDepositClientId,
                    identifierDepositClientSecret
                    )
                );
            var error = false;

            yield return(restSession.Open(
                             r =>
            {
                if (r.Error != null)
                {
                    onError.Invoke(r.Error);
                    error = true;
                }
            }
                             ));

            if (error)
            {
                yield return(restSession.Close(() => { }));

                yield break;
            }

            var restClient = new Gs2MoneyRestClient(
                restSession
                );

            yield return(restClient.DepositByUserId(
                             new DepositByUserIdRequest()
                             .WithNamespaceName(moneyNamespaceName)
                             .WithUserId(userId)
                             .WithSlot(slot)
                             .WithPrice(price)
                             .WithCount(value),
                             r =>
            {
                if (r.Error != null)
                {
                    onError.Invoke(r.Error);
                    error = true;
                }
                else
                {
                    onDeposit.Invoke(new EzWallet(r.Result.item), price, value);
                }
            }
                             ));

            yield return(restSession.Close(() => { }));
        }