Ejemplo n.º 1
0
        public void IssueShortTermTicket(int handle)
        {
            if (string.IsNullOrEmpty(Gamebase.GetUserID()) == true)
            {
                GamebaseLog.Warn("Not LoggedIn", this, "CompletePurchase");
                return;
            }

            GamebaseLog.Debug("Start", this, "IssueShortTermTicket");

            byte[] bytesForEncoding = Encoding.UTF8.GetBytes(ISSUE_SHORT_TERM_TICKET_PURPOSE);
            string encodedString    = Convert.ToBase64String(bytesForEncoding);

            var requestVO = AuthMessage.GetIssueShortTermTicketMessage(encodedString, ISSUE_SHORT_TERM_TICKET_EXPIRESIN);

            WebSocket.Instance.Request(requestVO, (response, error) =>
            {
                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <string> >(handle);
                if (callback == null)
                {
                    return;
                }

                GamebaseCallbackHandler.UnregisterCallback(handle);

                if (error == null)
                {
                    var vo = JsonMapper.ToObject <AuthResponse.IssueShortTermTicketInfo>(response);
                    if (vo.header.isSuccessful == true)
                    {
                    }
                    else
                    {
                        error = GamebaseErrorUtil.CreateGamebaseErrorByServerErrorCode(requestVO.transactionId, requestVO.apiId, vo.header, Domain);
                    }

                    callback(vo.ticket, error);
                }
                else
                {
                    callback(null, error);
                }
            });
        }