Пример #1
0
        /// <summary>
        /// 连接到移动设备
        /// </summary>
        /// <param name="mobileIPAddress"></param>
        /// <returns></returns>
        public void ConnectToMobile(string mobileIPAddress, ConnectedCallback onConnectionEvent)
        {
            Log.I("mobileIPAddres:{0}", mobileIPAddress);
            mSocketClient               = FlexiSocket.Create(mobileIPAddress, 1366, Protocols.BodyLengthPrefix);
            mSocketClient.Connected    += onConnectionEvent;
            mSocketClient.Disconnected += OnDisconnected;
            mSocketClient.Received     += OnReceived;
            mSocketClient.Sent         += OnSent;

            DelayNode delayNode = new DelayNode(1.0f)
            {
                OnEndedCallback = delegate
                {
                    mSocketClient.Connect();
                }
            };

            StartCoroutine(delayNode.Execute());
        }
Пример #2
0
        protected override void ProcessMsg(int key, QMsg msg)
        {
            Log.I("{0}", msg.EventID);
            switch (key)
            {
            case (ushort)UIFilterEvent.DelayLock:
                Log.I("receive");
                UILockOnClickEventMsg lockOnClickEventMsg = msg as UILockOnClickEventMsg;
                LockBtnOnClick = true;
                DelayNode delayNode = new DelayNode(lockOnClickEventMsg.LockTime)
                {
                    OnEndedCallback = delegate
                    {
                        LockBtnOnClick = false;
                    }
                };
                StartCoroutine(delayNode.Execute());
                break;

            case (ushort)UIFilterEvent.Lock:
                Log.I("Lock");
                Lock = true;
                break;

            case (ushort)UIFilterEvent.UnLock:
                Log.I("UnLock");
                Lock = false;
                break;

            case (int)UIFilterEvent.LockObjEvent:
            {
                UILockObjEventMsg lockObjEventMsg = msg as UILockObjEventMsg;
                if (null == LockedObj)
                {
                    LockedObj = lockObjEventMsg.LockedObj;
                }
                else if (LockedObj == lockObjEventMsg.LockedObj)
                {
                    // maybe two finger in one obj
                    Log.W("error: curLockedObj is already seted");
                }
                else if (LockedObj != lockObjEventMsg.LockedObj)
                {
                    throw new Exception("error: pre obj need unlocked");
                }
            }
            break;

            case (int)UIFilterEvent.UnlockObjEvent:
            {
                UIUnlockObjEventMsg unlockObjEventMsg = msg as UIUnlockObjEventMsg;
                if (unlockObjEventMsg.UnlockedObj == LockedObj)
                {
                    unlockObjEventMsg.UnlockedObj = null;
                    LockedObj = null;
                }
                else if (LockedObj == null)
                {
                    Log.W("error: curLockedObj is already unlocked");
                }
                else if (LockedObj != unlockObjEventMsg.UnlockedObj)
                {
                    throw new Exception("error: pre obj need unlocked");
                }
            }
            break;
            }
        }