public void startP2P(P2PSendInfo sendInfo, P2PSuccess success, P2PFail fail)
        {
            string childsn = sendInfo.childsn;

            string cupSn = sendInfo.cupSn;

            string petType = sendInfo.petType;

            int scanTimeOut = sendInfo.scanTimeOut;

            int waitTimeOut = sendInfo.waitTimeOut;

            if (!ValidSendInfo(sendInfo))
            {
                fail();
                return;
            }

            mP2PManager = new P2PManager((info) => {
                GuLog.Info("p2p info:" + "child_sn:" + info.child_sn + " cup_sn:" + info.cup_sn);
                mAddFriendsInfoManager.addFriend(info.cup_sn, DateUtil.GetTimeStamp());
                success(info);
            }, fail);

            mP2PManager.startP2P(childsn, cupSn, petType, scanTimeOut, waitTimeOut);
        }
 //重设息屏时间
 public void ResetSleepStatus()
 {
     this.topViewList.Clear();
     this.topViewList.Add(DEFAULT_SLEEP_TIME);
     Screen.sleepTimeout = int.MaxValue;
     GuLog.Info("<><SleepTimeManager>ResetSleepStatus");
 }
Ejemplo n.º 3
0
        public void InitialSilenceTimeSection(List <SilenceTimeSectionFromServer> listSilenceTimeSectionFromServer, bool needSave = true)
        {
            DumpSilenceTimeData(listSilenceTimeSectionFromServer);
            SaveSilenceTimeSection(listSilenceTimeSectionFromServer);

            List <SilenceTimeSection> listSilenceTimeSection = new List <SilenceTimeSection>();

            foreach (var section in listSilenceTimeSectionFromServer)
            {
                listSilenceTimeSection.Add(new SilenceTimeSection(section));
            }
            InitialSilenceTimeSection(listSilenceTimeSection);

            FillClocksItemList();

            if (listClocksItemSection.Count > 0)
            {
                GuLog.Debug("<><SilenceTimeDataManager>listClocksItemSection[0] hour:" + listClocksItemSection[0].clock_hour
                            + "minute:" + listClocksItemSection[0].clock_min);
                DumpClocksItemSection();
            }

            mCupClockManager.setOtherClock(mLocalChildInfoAgent.getChildSN(), listClocksItemSection, () =>
            {
                GuLog.Info("<><SilenceTimeDataManager>set other alrm success !");
            }, () =>
            {
                GuLog.Error("<SilenceTimeDataManager><>set other alrm error !");
            });
        }
Ejemplo n.º 4
0
 public void onBatteryLevelChange(int level)
 {
     Loom.QueueOnMainThread(() =>
     {
         GuLog.Info("<><InCharging>onBatteryLevelChange<><>" + level);
     });
 }
Ejemplo n.º 5
0
        public void uploadIntakeLogs(IntakeLogs mIntakeLogs, string current_child_sn, Action <UpLoadIntakeLogsResponseData> callBack, Action <ResponseErroInfo> errCallBack)
        {
            GuLog.Info("UploadChildIntakeLogsService uploadIntakeLogs");
            Dictionary <string, string> head = new Dictionary <string, string>();

            string body = mJsonUtils.Json2String(mIntakeLogs);

            // mGululuNetwork.sendRequest(mUrlProvider.getChildIntakeLogUrl(current_child_sn,CupBuild.getCupSn()), head, body, (result) =>
            // {

            // UpLoadIntakeLogsResponseData info = mJsonUtils.String2Json<UpLoadIntakeLogsResponseData>(result);
            //  mUploadChildIntakeLogsModel.mUpLoadIntakeLogsResponseData = info;
            // callBack(info);

            // }, (ecb) =>
            // {
            //     errCallBack(ecb);
            // }, HTTPMethods.Post);

            mNativeOkHttpMethodWrapper.post(mUrlProvider.getChildIntakeLogUrl(current_child_sn, CupBuild.getCupSn()), "", body, (result) => {
                GuLog.Info("UploadChildIntakeLogsService onresponse");
                UpLoadIntakeLogsResponseData info = mJsonUtils.String2Json <UpLoadIntakeLogsResponseData>(result);
                mUploadChildIntakeLogsModel.mUpLoadIntakeLogsResponseData = info;
                callBack(info);
            }, (errorResult) => {
                GuLog.Info("UploadChildIntakeLogsService faliure");
                errCallBack(errorResult);
            });
        }
Ejemplo n.º 6
0
        void onConnected()
        {
            GuLog.Info("<><InCharging><>onConnected<><>");

            RepeatBatteryUppdate();
            SoundPlayer.GetInstance().PlaySoundType("system_charging_start");
        }
        public void upload(Action <UpLoadIntakeLogsResponseData> callBack, Action <ResponseErroInfo> errCallBack)
        {
            GuLog.Info("IntakeLogDataManager upload");
            string currentChildSN = mLocalChildInfoAgent.getChildSN();

            if (currentChildSN == string.Empty)
            {
                errCallBack(ResponseErroInfo.GetErrorInfo(0, "upload resource is empty"));
                return;
            }
            List <LogItem> info = mLocalIntakeLogsData.getAllIntakeLogsInfo(currentChildSN);

            if (info != null && info.Count > 0)
            {
                GuLog.Info("IntakeLogDataManager havedata");
                IntakeLogs mIntakeLogs = new IntakeLogs();
                mIntakeLogs.logs = info;


                mUploadChildIntakeLogsService.uploadIntakeLogs(mIntakeLogs, currentChildSN, (cb) =>
                {
                    mLocalIntakeLogsData.deleteIntakeLogsInfo(currentChildSN);
                    callBack(cb);
                }, (ecb) =>
                {
                    errCallBack(ecb);
                });
            }
            else
            {
                errCallBack(ResponseErroInfo.GetErrorInfo(0, "upload resource is empty"));
            }
        }
Ejemplo n.º 8
0
 // Update is called once per frame
 void Update()
 {
     if (Time.deltaTime > 0.3f)
     {
         GuLog.Info("<><HeartBeatView>Long Frame:" + Time.deltaTime.ToString());
     }
 }
        private const string POP_SLEEP_STATUS = "Remove current status"; //出栈操作
        /************************************************构  造  函  数************************************************/

        /************************************************自 定 义 方 法************************************************/
        //息屏时间压栈
        public void AddSleepStatus(int sleepTimeout)
        {
            GuLog.Info("<><SleepTimeManager>AddSleepStatus: " + sleepTimeout);
            this.SetSleepTimeout(ADD_SLEEP_STATUS, sleepTimeout);
            topViewList.Add(sleepTimeout);
            this.PrintTrack(sleepTimeout);
        }
Ejemplo n.º 10
0
 private void _ProcessSilenceTime(DateTime time)
 {
     GuLog.Info("<><ProcessSilenceTime> time:" + time.ToShortTimeString());
     StopAllCoroutines();
     ProcessSilenceTime(SilenceTimeSection.SectionType.Study, time);
     ProcessSilenceTime(SilenceTimeSection.SectionType.Sleep, time);
 }
        public void sendRegisterCupRequest(Dictionary <string, string> head, string strbody)
        {
            Header headerentity = new Header();

            headerentity.headers = new List <HeaderData>();

            if (head != null)
            {
                foreach (KeyValuePair <string, string> headr in head)
                {
                    HeaderData data = new HeaderData();
                    data.key   = headr.Key;
                    data.value = headr.Value;
                    headerentity.headers.Add(data);
                }
            }

            string strHeader = mJsonUtils.Json2String(headerentity);


            mNativeOkHttpMethodWrapper.post(mUrlProvider.getRegisterUrl(AppData.GetAppName(), CupBuild.getCupSn()), strHeader, strbody, (result) =>
            {
                try
                {
                    GuLog.Info("Register response data :" + result);
                    RegisterResponseData info            = mJsonUtils.String2Json <RegisterResponseData>(result);
                    modelRegisterCup.responseRegisterCup = info;

                    Loom.QueueOnMainThread(() =>
                    {
                        if (mValidateResponseData.isValidRegisterResponseData(info))
                        {
                            //Debug.LogFormat("--------SaveSN--------RegisterCupService.sendRegisterCupRequest: {0}", info.x_child_sn);
                            saveData(info);
                            serviceRegisterCupBackSignal.Dispatch(info);
                        }
                        else
                        {
                            Debug.LogError("response data is invalid:" + result);
                            serviceRegisterCupErrBackSignal.Dispatch(ResponseErroInfo.GetErrorInfo(GululuErrorCode.RESPONSE_DATA_ERROR, "response data is invalid"));
                        }
                    });
                }
                catch
                {
                    Loom.QueueOnMainThread(() =>
                    {
                        Debug.LogError("response data is error:" + result);
                        serviceRegisterCupErrBackSignal.Dispatch(ResponseErroInfo.GetErrorInfo(GululuErrorCode.RESPONSE_DATA_ERROR, "response data is error"));
                    });
                }
            }, (errorResult) =>
            {
                Loom.QueueOnMainThread(() =>
                {
                    serviceRegisterCupErrBackSignal.Dispatch(errorResult);
                });
            });
        }
Ejemplo n.º 12
0
 void onDisconnected()
 {
     TopViewHelper.Instance.RemoveView(TopViewHelper.ETopView.eInCharge);
     lowBattery.StartLowBattery();
     gameObject.SetActive(false);
     GuLog.Info("<><InCharging>onDisconnected<><>");
     CancelInvoke("BatteryUpdate");
 }
 public void onFailure()
 {
     GuLog.Info("NativeOkHttpMethodWrapperCallBack: onFailure");
     if (mNativeOnFailure != null)
     {
         mNativeOnFailure(ResponseErroInfo.GetErrorInfo(-1, "http io error"));
     }
 }
Ejemplo n.º 14
0
 public void onStart()
 {
     GuLog.Info("HeartbeatListener onStart");
     if (mHeartBeatReveive != null)
     {
         mHeartBeatReveive();
     }
 }
 public override void onStart()
 {
     GuLog.Info("<><IntakeHeartbeatAction> Time:" + DateTime.Now.ToShortTimeString());
     mIntakeLogDataManager.upload((result) => {
         onFinish();
     }, (errorInfo) => {
         onFinish();
     });
 }
 public override void onStart()
 {
     GuLog.Info("<><UploadFriendsHeatbeatAction> Time:" + DateTime.Now.ToShortTimeString());
     mAddFriendsInfoManager.upload((result) => {
         onFinish();
     }, (errorInfo) => {
         onFinish();
     });
 }
 //当息屏时间改变时
 private void OnSleepStatusChanged(string operate, int seconds)
 {
     GuLog.Info(string.Format("<><SleepTimeManager>OnSleepStatusChanged: {0}, {1}", operate, seconds));
     GuLog.Info(TopViewHelper.Instance.ToString());
     if (this.SleepStatusChanged != null)
     {
         this.SleepStatusChanged(operate, seconds);
     }
 }
Ejemplo n.º 18
0
 void DumpSilenceTimeData(List <SilenceTimeSectionFromServer> listSilenceTimeSectionFromServer)
 {
     for (int i = 0; i < listSilenceTimeSectionFromServer.Count; ++i)
     {
         SilenceTimeSectionFromServer data = listSilenceTimeSectionFromServer[i];
         if (data.enable != 0)
         {
             GuLog.Info("<><SilenceTimeData>type:" + data.type + "   enable:" + data.enable + "    begin:" + data.start_hour + ":" + data.start_min + "    end:" + data.end_hour + ":" + data.end_min + "    days:" + data.weekdays);
         }
     }
 }
Ejemplo n.º 19
0
        public override void onStart()
        {
            if (TopViewHelper.Instance.IsInGuideView())
            {
                return;
            }

            GuLog.Info("<><GameHeartbeatAction> Time:" + DateTime.Now.ToShortTimeString());
            //syncAllGameDataSingal.Dispatch();
            startHeartBeatCommandSignal.Dispatch();
        }
Ejemplo n.º 20
0
 void DumpClocksItemSection()
 {
     for (int i = 0; i < listClocksItemSection.Count; ++i)
     {
         ClocksItem data = listClocksItemSection[i];
         if (data.clock_enable != 0)
         {
             GuLog.Info("<><SilenceTimeData>type:" + data.clock_type + "   enable:" + data.clock_enable + "    begin:" + data.clock_hour + ":" + data.clock_min + "    days:" + data.clock_weekdays);
         }
     }
 }
Ejemplo n.º 21
0
 //页面入栈
 public void AddTopView(ETopView view)
 {
     if (this.silenceViewList.ContainsKey(view))
     {//静默页面状态置为打开
         this.silenceViewList[view] = true;
     }
     else if (!topViewList.Contains(view))
     {//记录普通页面
         topViewList.Add(view);
         this.OnViewChanged(ADD_VIEW, view);
     }
     GuLog.Info(this.ToString());
 }
Ejemplo n.º 22
0
 //页面出栈
 public void RemoveView(ETopView view)
 {
     if (this.silenceViewList.ContainsKey(view))
     {//静默页面状态置为关闭
         this.silenceViewList[view] = false;
     }
     else if (topViewList.Count > 0 && this.TopView != ETopView.eMainView && topViewList.Contains(view))
     {//移除普通页面
         topViewList.Remove(view);
         this.OnViewChanged(REMOVE_VIEW, this.TopView);
     }
     GuLog.Info(this.ToString());
 }
        public void startHeartbeat()
        {
            int size = mHeartbeatActions.Count;

            GuLog.Info("HeartbearActionManager size: " + size);
            if (size <= 0)
            {
                mHeartbeatManager.notifyHeartBeatDone();
            }
            else
            {
                handleHeartBeat(size);
            }
        }
 //打印上层调用Track
 private void PrintTrack(int sleepTimeout)
 {
     if (sleepTimeout == SleepTimeout.NeverSleep)
     {
         string       info = null;
         StackTrace   st   = new StackTrace(true);
         StackFrame[] sf   = st.GetFrames();
         for (int i = 0; i < sf.Length; ++i)
         {
             info = info + "\r\n" + " FileName=" + sf[i].GetFileName() + " fullname=" + sf[i].GetMethod().DeclaringType.FullName + " function=" + sf[i].GetMethod().Name + " FileLineNumber=" + sf[i].GetFileLineNumber();
         }
         GuLog.Info("sleep == -1 trace: " + info);
     }
 }
        public void Done()
        {
            lock (mObject)
            {
                mCount--;

                if (mCount == 0 && mDoAction != null)
                {
                    mDoAction();
                }
            }

            GuLog.Info("HeartbeatCountDownLatch count: " + mCount);
        }
Ejemplo n.º 26
0
        public void sendRequest(string url, IDictionary <string, string> headrs, Action <string> callBack, Action <ResponseErroInfo> errCallBack, HTTPMethods methods)
        {
            string requestInfo = "mothod:" + methods + " url:" + url;

            GuLog.Info("GululuNetwork", requestInfo);

            HTTPRequest hTTPRequest = new HTTPRequest(new Uri(url), methods);

            hTTPRequest.Tag            = RequestRetryInfo.allRetryCount;
            hTTPRequest.ConnectTimeout = TimeSpan.FromSeconds(20);
            hTTPRequest.Timeout        = TimeSpan.FromSeconds(20);
            hTTPRequest.Callback       = createRequestCallBack(callBack, errCallBack);
            setHeader(hTTPRequest, headrs);
            hTTPRequest.Send();
        }
        private void handleHeartBeat(int size)
        {
            GuLog.Info("HeartbearActionManager mHeartbeatActions");
            HeartbeatCountDownLatch mHeartbeatCountDownLatch = new HeartbeatCountDownLatch();

            mHeartbeatCountDownLatch.SetCount(size);
            mHeartbeatCountDownLatch.setAction(() => {
                mHeartbeatManager.notifyHeartBeatDone();
            });
            for (int i = 0; i < size; i++)
            {
                IAbsDoHeartbeatAction action = mHeartbeatActions[i];
                action.setHeartbeatCountDownLatch(mHeartbeatCountDownLatch);
                action.onStart();
            }
        }
Ejemplo n.º 28
0
        public void handleResqAndResp(HTTPRequest originalRequest, HTTPResponse response, Action <string> callBack, Action <ResponseErroInfo> errCallBack)
        {
            Debug.Log("<><>handleResqAndResp<><>" + originalRequest.State);
            int oddRetryCount = getOddRetryCount(originalRequest);

            switch (originalRequest.State)
            {
            case HTTPRequestStates.Finished:
                string requestInfo = "Response url:" + originalRequest.Uri.AbsolutePath + " body:" + response.DataAsText;

                GuLog.Info(requestInfo);
                if (response.IsSuccess)
                {
                    callBack(response.DataAsText);
                }
                else
                {
                    handleResponseError(originalRequest, response, errCallBack);
                }
                break;

            case HTTPRequestStates.Aborted:
                errCallBack(ResponseErroInfo.GetErrorInfo(LocalRequestStatusCode.Aborted, "Request Aborted"));
                break;

            case HTTPRequestStates.Initial:
                errCallBack(ResponseErroInfo.GetErrorInfo(LocalRequestStatusCode.Initial, "Request Initial"));
                break;

            case HTTPRequestStates.Processing:
                errCallBack(ResponseErroInfo.GetErrorInfo(LocalRequestStatusCode.Processing, "Request Processing"));
                break;

            case HTTPRequestStates.Queued:
                errCallBack(ResponseErroInfo.GetErrorInfo(LocalRequestStatusCode.Queued, "Request Queued"));
                break;

            case HTTPRequestStates.Error:
                sendRetryRequest(oddRetryCount, errCallBack, originalRequest, "Error");
                break;

            case HTTPRequestStates.ConnectionTimedOut:
            case HTTPRequestStates.TimedOut:
                sendRetryRequest(oddRetryCount, errCallBack, originalRequest, "TimedOut");
                break;
            }
        }
Ejemplo n.º 29
0
 public bool IsActionOnPlaying(string strAni)
 {
     if (animator && gameObject.activeInHierarchy)
     {
         AniAndSound info = ActionConifg.GetAniAndSound(PetName, strAni);
         if (info != null)
         {
             AnimatorStateInfo stateinfo = animator.GetCurrentAnimatorStateInfo(0);
             return(stateinfo.IsName(info.AniName));
         }
         else
         {
             GuLog.Info("Not Action:" + strAni + "   in Pet model:" + PetName);
         }
     }
     return(true);
 }
        //         [Inject]
        //         public HeartBeatBody body { set; get; }

        public override void Execute()
        {
            GuLog.Info("<><HeartBeatCommand> Execute!");
            if (mLocalChildInfoAgent.getChildSN() == null || mLocalChildInfoAgent.getChildSN() == string.Empty)
            {
                GuLog.Info("<><HeartBeatCommand> child sn null!");
                FinishAndDispatchResult(ResponseErroInfo.GetErrorInfo(100, "child sn null!"));
                return;
            }
            getHeartBeatService.serviceHeartBeatBackSignal.AddListener(HeartBeatResult);
            getHeartBeatService.serviceHeartBeatErrBackSignal.AddListener(HeartBeatResultErr);

            SChild child = SChild.getBuilder().setFriend_count(10)
                           .setX_child_sn(mLocalChildInfoAgent.getChildSN()).setLanguage(languageUtils.getLanguageToAgentKey()).build();

            CupBuild.getCupHwMac((mac) => {
                Debug.Log("HeartBeatCommand mac:" + mac);
                SCup cup = SCup.getBuilder().setCup_hw_mac(mac)
#if UNITY_EDITOR
                           .setBattery(50)
                           .setCharge(false)
                           .setCapability(0)
                           .build();
#else
                           .setBattery(BatteryUtils.getBatteryCapacity(AndroidContextHolder.GetAndroidContext()))
                           .setCharge(BatteryUtils.isCharging(AndroidContextHolder.GetAndroidContext()))
                           .setCapability(0)
                           .build();
#endif
                SGame game = SGame.getBuilder()
                             .setGame_name(AppData.GetAppName())
#if UNITY_EDITOR
                             .setGame_version("1.0.31")
#else
                             .setGame_version(CupBuild.getAppVersionName())
#endif
                             .setPet_model(mLocalPetInfoAgent.getCurrentPet()).build();

                SExtra extra = SExtra.getBuilder().setTimestamp(DateUtil.GetTimeStamp()).setTimezone(8).build();

                HeartBeatBody body = HeartBeatBody.getBuilder().setChild(child).setCup(cup).setGame(game).setExtra(extra).build();


                getHeartBeatService.HeartBeat(body);
            });