Exemplo n.º 1
0
        private void StartResquestForBind(String deviceId)
        {
            Dictionary <string, object> paramDict = new Dictionary <string, object>();

            paramDict.Add("deviceId", deviceId);
            paramDict.Add("userId", PlayerPrefsUtil.GetUserId());
            HttpUtil.PostWithSign <BindResultModel>(UrlConst.Bind, paramDict)
            .Subscribe(response =>
            {
                if (response.bindRelation == 1)
                {
                    UIMgr.OpenPanel <TipPanel>(new TipPanelData()
                    {
                        action             = TipAction.BindDevice,
                        message            = "该账号已绑定其他设备,\n如需绑定当前设备,需解绑后重新绑定",
                        isHideCancelButton = true,
                        strConfirm         = "知道了"
                    });
                    StopAllCoroutines();
                }
                else
                {
                    ConnectResult(true);
                    StopAllCoroutines();
                }

                /**
                 * 停止播放音频
                 */
                if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    IOSClientUtil.StopBindDevice("");
                }
                else if (Application.platform == RuntimePlatform.Android)
                {
                    AndroidForUnity.CallAndroidForStopDeviceConnect();
                }
            }
                       , e =>
            {
                if (e is HttpException)
                {
                    ConnectResult(false);
                    HttpException http = e as HttpException;
                    Log.E("弹吐司" + http.Message);
                }
            }).AddTo(this);
        }
Exemplo n.º 2
0
        public static void DoTransition <TDstPanel>(this UIPanel selfBehaviour, UITransition transition,
                                                    UILevel uiLevel        = UILevel.Common,
                                                    IUIData uiData         = null,
                                                    string assetBundleName = null,
                                                    string prefabName      = null) where TDstPanel : UIPanel
        {
            transition.FromPanel   = selfBehaviour;
            transition.InCompleted = () =>
            {
                UIMgr.OpenPanel <TDstPanel>(uiLevel, uiData, assetBundleName, prefabName);
            };


            UIMgr.OpenPanel <UITransitionPanel>(UILevel.Forward, new UITransitionPanelData()
            {
                Transition = transition
            }, prefabName: "Resources/UITransitionPanel");
        }
Exemplo n.º 3
0
        private IEnumerator Start()
        {
            UIMgr.OpenPanel <UIMsg>();

            mHostIp = NetworkUtil.GetAddressIP();

            mSocketServer = FlexiSocket.Create(1366, Protocols.BodyLengthPrefix, false);
            mSocketServer.ClientConnected += delegate(ISocketClientToken client)
            {
                Log.I("OnClientConnected ID:{0} Count:{1}", client.ID, mSocketServer.Clients.Count);
            };
            mSocketServer.SentToClient += delegate(bool success, ISocketClientToken client)
            {
                if (success)
                {
                }
            };

            mSocketServer.ReceivedFromClient += delegate(ISocketClientToken client, byte[] message)
            {
                SocketMsg msg = SerializeHelper.FromProtoBuff <SocketMsg>(message);
                mMessage = msg.msgId + ":" + msg.ToEventID;
                if (!string.IsNullOrEmpty(msg.Msg))
                {
                    mMessage += ":" + msg.Msg;
                }
                Log.I("OnReceivedFromClient:{0}", mMessage);
                mMsgQueue.Enqueue(msg);
            };

            mSocketServer.ClientDisconnected += delegate(ISocketClientToken client)
            {
            };
            mSocketServer.StartListen(10);

            yield return(0);
        }
Exemplo n.º 4
0
        protected override void OnInit(QFramework.IUIData uiData)
        {
            mData = uiData as ConnectDevicePanelData ?? new ConnectDevicePanelData();
            Meteors.transform.DOLocalMoveX(-2370, 5f).SetLoops(-1, LoopType.Restart);
            Meteors.transform.DOLocalMoveY(-470, 5f).SetLoops(-1, LoopType.Restart);

            Dictionary <string, object> param = new Dictionary <string, object>();

            param.Add("ssid", mData.SSIDStr);
            param.Add("password", mData.SSIDPWD);
            param.Add("token", PlayerPrefsUtil.GetToken());
            param.Add("userId", PlayerPrefsUtil.GetUserId());
            if (Application.platform == RuntimePlatform.Android)
            {
                AndroidForUnity.CallAndroidForStartDeviceConnect(mData.SSIDStr, mData.SSIDPWD);
            }
            else if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                IOSClientUtil.StartBindDevice(param.ToJson());
            }

            StartCoroutine(CountDown());

            BtnBack.OnClickAsObservable().Subscribe(_ =>
            {
                UIMgr.OpenPanel <TipPanel>(new TipPanelData()
                {
                    action     = TipAction.BindingBack,
                    message    = "返回后联网将不在继续,确认终止操作?",
                    strConfirm = "确定",
                    strCancel  = "继续等待",
                    strTitle   = "终止配网",
                });
            }).AddTo(this);

            BtnCheckWiFi.OnClickAsObservable().Subscribe(_ =>
            {
                UIMgr.OpenPanel <BindCheckWIFIPanel>(new BindCheckWIFIPanelData(), UITransitionType.NULL);
            }).AddTo(this);

            SimpleEventSystem.GetEvent <BindDeviceResult>().Subscribe(res =>
            {
                BindDeviceModel model = res.Model;

                if (Application.platform == RuntimePlatform.Android)
                {
                    if (model.status == 1)
                    {
                        StartResquestForBind(model.deviceId);
                    }
                    else
                    {
                        ConnectResult(false);
                    }
                }
                else if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    if (model.requestTag == 2 && model.deviceId.IsNotNullAndEmpty())
                    {
                        StartResquestForBind(model.deviceId);
                    }

                    if (model.requestTag == 1)
                    {
                        CommonUtil.toast("获取音频接口出错");
                    }
                }
            }).AddTo(this);

            SimpleEventSystem.GetEvent <TipConfirmClick>()
            .Subscribe(_ =>
            {
                if (_.GetAction == TipAction.BindDevice)
                {
                    ShowMainPanel();
                }
                else if (_.GetAction == TipAction.BindingBack)
                {
                    StopAllCoroutines();
                    if (Application.platform == RuntimePlatform.IPhonePlayer)
                    {
                        IOSClientUtil.StopBindDevice("");
                    }
                    else if (Application.platform == RuntimePlatform.Android)
                    {
                        AndroidForUnity.CallAndroidForStopDeviceConnect();
                    }
                    Back();
                }
            }).AddTo(this);
        }