Ejemplo n.º 1
0
        public static WebSocketRequest.RequestVO GetHeartbeatMessage()
        {
            var vo = new LaunchingRequest.HeartBeatVO();

            vo.parameter.appId           = GamebaseUnitySDK.AppID;
            vo.payload.appId             = GamebaseUnitySDK.AppID;
            vo.payload.clientVersion     = GamebaseUnitySDK.AppVersion;
            vo.payload.deviceCountryCode = GamebaseUnitySDK.CountryCode;
            vo.payload.osCode            = GamebaseUnitySDK.Platform;

            if (string.IsNullOrEmpty(Gamebase.GetUserID()))
            {
                vo.payload.userId = "0";
            }
            else
            {
                vo.payload.userId = Gamebase.GetUserID();
            }

            vo.payload.usimCountryCode = "ZZ";
            vo.payload.storeCode       = GamebaseUnitySDK.StoreCode;
            vo.payload.idpCode         = GamebaseAnalytics.Instance.IdPCode;
            vo.payload.deviceModel     = GamebaseUnitySDK.DeviceModel;


            var requestVO = new WebSocketRequest.RequestVO(Lighthouse.API.Presence.PRODUCT_ID, Lighthouse.API.VERSION, GamebaseUnitySDK.AppID);

            requestVO.apiId      = Lighthouse.API.Presence.ID.HEARTBEAT;
            requestVO.parameters = vo.parameter;
            requestVO.payload    = JsonMapper.ToJson(vo.payload);
            return(requestVO);
        }
            public RequestQueueItem(int index, WebSocketRequest.RequestVO requestVO, GamebaseCallback.GamebaseDelegate <string> callback)
            {
                this.requestVO = requestVO;
                this.callback  = callback;

                this.index = index;
                retryCount = 0;
            }
        public static WebSocketRequest.RequestVO GetIDPLoginMessage(
            string providerName,
            string accessToken       = null,
            string authorizationCode = null)
        {
            var launchingInfoVO = DataContainer.GetData <LaunchingResponse.LaunchingInfo>(VOKey.Launching.LAUNCHING_INFO);
            var idpDic          = launchingInfoVO.launching.app.idP;

            var vo = new AuthRequest.LoginVO();

            vo.parameter.appId = GamebaseUnitySDK.AppID;

            if (providerName == GamebaseAuthProvider.GUEST)
            {
                vo.payload.idPInfo.accessToken = string.Format("GAMEBASE{0}", GamebaseUnitySDK.UUID);
            }
            else
            {
                vo.payload.idPInfo.accessToken = accessToken;
            }

            vo.payload.idPInfo.authorizationCode = authorizationCode;
            vo.payload.idPInfo.clientId          = idpDic[providerName].clientId;
            vo.payload.idPInfo.clientSecret      = idpDic[providerName].clientSecret;
            vo.payload.idPInfo.idPCode           = providerName;
            vo.payload.member.clientVersion      = GamebaseUnitySDK.AppVersion;
            vo.payload.member.deviceCountryCode  = GamebaseUnitySDK.CountryCode;
            vo.payload.member.deviceKey          = GamebaseUnitySDK.DeviceKey;
            vo.payload.member.deviceModel        = GamebaseUnitySDK.DeviceModel;
            vo.payload.member.osVersion          = GamebaseUnitySDK.OsVersion;
            vo.payload.member.deviceLanguage     = GamebaseUnitySDK.DeviceLanguageCode;
            vo.payload.member.displayLanguage    = GamebaseUnitySDK.DisplayLanguageCode;
            vo.payload.member.network            = Application.internetReachability.ToString();
            vo.payload.member.osCode             = GamebaseUnitySDK.Platform;
            vo.payload.member.sdkVersion         = GamebaseUnitySDK.SDKVersion;
            vo.payload.member.storeCode          = launchingInfoVO.launching.app.storeCode;
            vo.payload.member.telecom            = string.Empty;
            vo.payload.member.usimCountryCode    = "ZZ";
            vo.payload.member.uuid = GamebaseUnitySDK.UUID;

            WebSocketRequest.RequestVO requestVO = new WebSocketRequest.RequestVO(
                Lighthouse.API.Gateway.PRODUCT_ID,
                Lighthouse.API.VERSION,
                GamebaseUnitySDK.AppID);

            requestVO.apiId      = Lighthouse.API.Gateway.ID.IDP_LOGIN;
            requestVO.parameters = vo.parameter;
            requestVO.payload    = JsonMapper.ToJson(vo.payload);

            return(requestVO);
        }
        public static WebSocketRequest.RequestVO GetWithdrawMessage()
        {
            var vo = new AuthRequest.WithdrawVO();

            vo.parameter.appId  = GamebaseUnitySDK.AppID;
            vo.parameter.userId = Gamebase.GetUserID();

            WebSocketRequest.RequestVO requestVO = new WebSocketRequest.RequestVO(
                Lighthouse.API.Gateway.PRODUCT_ID,
                Lighthouse.API.VERSION,
                GamebaseUnitySDK.AppID);

            requestVO.apiId      = Lighthouse.API.Gateway.ID.WITHDRAW;
            requestVO.parameters = vo.parameter;

            return(requestVO);
        }
        public static WebSocketRequest.RequestVO GetIssueShortTermTicketMessage(string purpose, int expiresIn)
        {
            AuthRequest.IssueShortTermTicketVO vo = new AuthRequest.IssueShortTermTicketVO();

            vo.parameter.userId    = Gamebase.GetUserID();
            vo.parameter.purpose   = purpose;
            vo.parameter.expiresIn = expiresIn;

            WebSocketRequest.RequestVO requestVO = new WebSocketRequest.RequestVO(
                Lighthouse.API.Gateway.PRODUCT_ID,
                Lighthouse.API.VERSION,
                GamebaseUnitySDK.AppID);

            requestVO.apiId      = Lighthouse.API.Gateway.ID.ISSUE_SHORT_TERM_TICKET;
            requestVO.parameters = vo.parameter;

            return(requestVO);
        }
        public static WebSocketRequest.RequestVO GetLogoutMessage()
        {
            var loginInfoVO = DataContainer.GetData <AuthResponse.LoginInfo>(VOKey.Auth.LOGIN_INFO);
            var vo          = new AuthRequest.LogoutVO();

            vo.parameter.appId       = GamebaseUnitySDK.AppID;
            vo.parameter.userId      = loginInfoVO.member.userId;
            vo.parameter.accessToken = loginInfoVO.token.accessToken;

            WebSocketRequest.RequestVO requestVO = new WebSocketRequest.RequestVO(
                Lighthouse.API.Gateway.PRODUCT_ID,
                Lighthouse.API.VERSION,
                GamebaseUnitySDK.AppID);

            requestVO.apiId      = Lighthouse.API.Gateway.ID.LOGOUT;
            requestVO.parameters = vo.parameter;

            return(requestVO);
        }
        public void Request(WebSocketRequest.RequestVO vo, GamebaseCallback.GamebaseDelegate <string> callback)
        {
            GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.WEBSOCKET_TYPE, InternetReachability((reachable) =>
            {
                if (true == reachable)
                {
                    RequestEnqueue(new RequestQueueItem(itemLength++, vo, callback));
                }
                else
                {
                    if (null == callback)
                    {
                        return;
                    }

                    callback(string.Empty, new GamebaseError(GamebaseErrorCode.SOCKET_ERROR, transactionId: vo.transactionId));
                }
            }));
        }