public void OnBeginDrag(PointerEventData eventData)
 {
     if (onDragStart != null)
     {
         onDragStart.SafeInvoke(eventData);
     }
 }
Beispiel #2
0
        private void DoConfirmPendingPurchaseByIDIOS(string platform_unique_Id)
        {
            Product product = m_StoreController.products.WithID(platform_unique_Id);

            if (product != null && product.availableToPurchase)
            {
                //product.metadata.localizedDescription,
                // product.metadata.isoCurrencyCode
                //product.metadata.localizedPrice.ToString(),
                //product.metadata.localizedPriceString,
                Debug.Log("UNITY IAP confirm ok !!!!!!!!!!!!!!!!");

                if (!m_Usr_Transction_Done_IOS.IsNull)
                {
                    m_Usr_Transction_Done_IOS.SafeInvoke(platform_unique_Id, product.metadata.isoCurrencyCode, product.metadata.localizedPrice.ToString());
                }

                if (m_PurchaseInProgress)
                {
                    m_StoreController.ConfirmPendingPurchase(product);
                    m_PurchaseInProgress = false;
                }
                else
                {
                    m_StoreController.ConfirmPendingPurchase(product);
                }
            }
        }
Beispiel #3
0
        public void OnPointerDown(UnityEngine.EventSystems.PointerEventData eventData)
        {
            Vector2 pos = eventData.position;

            //显示特效
            PointerDown.SafeInvoke(pos);
        }
 public void OnEndDrag(PointerEventData eventData)
 {
     if (onDragEnd != null)
     {
         onDragEnd.SafeInvoke(eventData);
     }
 }
        private TaskWrapper PrepareAndSend(string deviceId, string jsonData)
        {
            var msg = PrepareMessage(jsonData);

            var sh = new SafeAction <Message>(m => deviceClients[deviceId].SendEventAsync(msg), Logger);

            return(TaskWrapper.Run(() => sh.SafeInvoke(msg)));
        }
        public void Start(SensorEndpoint endpoint, int messagesToSend)
        {
            _messagesToSend = messagesToSend;
            _endpoint       = endpoint;
            _doWorkSwitch   = true;

            var sh = new SafeAction <int>(e => RunSocketAsClient(e), _logger);

            TaskWrapper.Run(() => sh.SafeInvoke(CONNECTION_RETRIES));
        }
Beispiel #7
0
        private TaskWrapper PrepareAndSend(string jsonData)
        {
            Message msg = PrepareMessage(jsonData);
            // send to the cloud asynchronously, but wait for completetion
            // this is actually serializing access to the SenderLink type

            var sh = new SafeAction <Message>(m => SendAmqpMessage(m), Logger);

            return(TaskWrapper.Run(() => sh.SafeInvoke(msg)));
        }
Beispiel #8
0
        private void OnBackClicked(GameObject obj_)
        {
            EngineCoreEvents.AudioEvents.PlayAudio.SafeInvoke(Audio.AudioType.UISound, EngineCommonAudioKey.Button_Click_Common.ToString());
            this.Visible = false;

            if (!m_onBack.IsNull)
            {
                m_onBack.SafeInvoke();
            }
        }
Beispiel #9
0
        static void HandleResult(IResult result)
        {
            string LastResponse = "";

            if (result == null)
            {
                LastResponse = "FACEBOOK: invite Null Response\n";
                Debug.LogError(LastResponse);
                OnShareLinkResult.SafeInvoke(LastResponse);
                return;
            }


            string Status = "";

            // Some platforms return the empty string instead of null.
            if (!string.IsNullOrEmpty(result.Error))
            {
                Status       = "FACEBOOK: inviteError - Check log for details";
                LastResponse = "FACEBOOK: inviteError Response:\n" + result.Error;
                OnShareLinkResult.SafeInvoke(LastResponse);
            }
            else if (result.Cancelled)
            {
                Status       = "FACEBOOK: inviteCancelled - Check log for details";
                LastResponse = "FACEBOOK: inviteCancelled Response:\n" + result.RawResult;
                OnShareLinkResult.SafeInvoke(LastResponse);
            }
            else if (!string.IsNullOrEmpty(result.RawResult))
            {
                Status       = "FACEBOOK: inviteSuccess - Check log for details";
                LastResponse = "FACEBOOK: inviteSuccess Response:\n" + result.RawResult;
            }
            else
            {
                LastResponse = "FACEBOOK: inviteEmpty Response\n";
                OnShareLinkResult.SafeInvoke(LastResponse);
            }

            Debug.Log(string.Format("FACEBOOK: Status = {0},  Responce = {1}", Status, LastResponse));
        }
        public override bool Start(Func <string, int> enqueue)
        {
            _enqueue = enqueue;

            _doWorkSwitch = true;

            var sh = new SafeAction <int>((t) => RunForSocket(t), _logger);

            TaskWrapper.Run(() => sh.SafeInvoke(CONNECTION_RETRIES));

            return(true);
        }
        public override bool Start( Func<string, int> enqueue )
        {
            _enqueue = enqueue;

            _doWorkSwitch = true;

            var sh = new SafeAction<int>( ( t ) => RunForSerial( t ), _logger );

            TaskWrapper.Run( ( ) => sh.SafeInvoke( SLEEP_TIME_BETWEEN_SCAN ) );

            return true;
        }
        public override bool Start(Func <string, int> enqueue)
        {
            _enqueue = enqueue;

            _doWorkSwitch = true;

            var sh = new SafeAction <int>((t) => RunForSerial(t), _logger);

            TaskWrapper.Run(() => sh.SafeInvoke(SLEEP_TIME_BETWEEN_SCAN));

            return(true);
        }
Beispiel #13
0
        private void SendOutcome(Message message, Outcome outcome, object state)
        {
            int sent = Interlocked.Increment(ref _sentMessages);

            string messageToLog = Encoding.UTF8.GetString(message.Encode( ).Buffer);

            int jsonBracketIndex = messageToLog.IndexOf("{", System.StringComparison.Ordinal);

            if (jsonBracketIndex > 0)
            {
                messageToLog = messageToLog.Substring(jsonBracketIndex);
            }

            jsonBracketIndex = messageToLog.LastIndexOf("}", System.StringComparison.Ordinal);
            if (jsonBracketIndex > 0)
            {
                messageToLog = messageToLog.Substring(0, jsonBracketIndex + 1);
            }

            if (outcome is Accepted)
            {
#if DEBUG_LOG
                Logger.LogInfo("Message is accepted");
#endif

                if (sent == 1)
                {
                    _start = DateTime.Now;
                }

                if (Interlocked.CompareExchange(ref _sentMessages, 0, Constants.MessagesLoggingThreshold) == Constants.MessagesLoggingThreshold)
                {
                    DateTime now = DateTime.Now;

                    TimeSpan elapsed = (now - _start);

                    _start = now;

                    var sh = new SafeAction <String>(s => Logger.LogInfo(s), Logger);

                    TaskWrapper.Run(() => sh.SafeInvoke(
                                        String.Format("GatewayService sent {0} events to Event Hub succesfully in {1} ms ",
                                                      Constants.MessagesLoggingThreshold, elapsed.TotalMilliseconds.ToString( ))));
                }
            }
            else
            {
#if DEBUG_LOG
                Logger.LogInfo("Message is rejected: " + messageToLog);
#endif
            }
        }
        public override bool Start(Func <string, int> enqueue)
        {
            _enqueue = enqueue;

            _doWorkSwitch = true;

            //var sh = new SafeAction<int>( ( t ) => RunSocketAsClient( t ), _logger );
            var sh = new SafeAction(() => RunSocketServer( ), _logger);

            TaskWrapper.Run(() => sh.SafeInvoke( ));

            return(true);
        }
        public override bool Start( Func<string, int> enqueue )
        {
            _enqueue = enqueue;

            _doWorkSwitch = true;

            //var sh = new SafeAction<int>( ( t ) => RunSocketAsClient( t ), _logger );
            var sh = new SafeAction( ( ) => RunSocketServer( ), _logger );

            TaskWrapper.Run( ( ) => sh.SafeInvoke( ) );

            return true;
        }
        protected virtual void DataInQueue(QueuedItem data)
        {
            DataInQueueEventHandler newData = OnDataInQueue;

            if (newData != null)
            {
                var sh = new SafeAction <QueuedItem>(d => newData(d), Logger);

                TaskWrapper.Run(() => sh.SafeInvoke(data));
            }

            //
            // NO logging on production code, enable for diagnostic purposes for debugging
            //
#if DEBUG_LOG
            LogMessageReceived( );
#endif
        }
Beispiel #17
0
        public void Refresh(int id_, string icon_name_, string info_, bool checked_, Action <bool, int> clicked_, Action <bool, int> pressed_)
        {
            this.m_item_id         = id_;
            this.m_icon_img.Sprite = icon_name_;

            this.m_onItemIsClicked = clicked_;

            this.m_onItemIsLongPressed = pressed_;

            if (checked_)
            {
                m_selected_icon.Visible = true;
                m_onItemIsClicked.SafeInvoke(checked_, this.m_item_id);
            }
            else
            {
                m_selected_icon.Visible = false;
            }
        }
Beispiel #18
0
        public override void OnHide()
        {
            base.OnHide();
            //this.m_tweenPosHide.ResetAndPlay();
            //this.m_TweenAlphaHide.ResetAndPlay();
            this.m_buy_btn.RemoveClickCallBack(OnBuyClicked);
            this.m_left_btn.RemoveClickCallBack(OnLeftClicked);
            this.m_right_btn.RemoveClickCallBack(OnRightClicked);
            this.m_close_btn.RemoveClickCallBack(OnCloseClicked);
            this.m_detail_btn.RemoveClickCallBack(OnDetailClicked);
            this.m_detail_root.RemoveClickCallBack(OnDetailCloseClicked);
            this.RemoveClickCallBack(OnDetailCloseClicked);
            GameEvents.IAPEvents.OnTransactionDone -= DisableItem;

            OnClosed.SafeInvoke();
            GameEvents.UIEvents.UI_Bonus_Pop_View_Event.Tell_OnBlock.SafeInvoke(false);
            GameEvents.UIEvents.UI_Bonus_Pop_View_Event.Tell_OnShow.SafeInvoke();

            m_detail_root.Visible = false;
        }
Beispiel #19
0
        //--//

        public TaskWrapper SendMessage(T data)
        {
            Action <T> send = (d) =>
            {
                lock ( _sentMessages )
                {
                    if (_sentMessages.ContainsKey(d))
                    {
                        _sentMessages[d]++;
                    }
                    else
                    {
                        _sentMessages.Add(d, 1);
                    }
                }
            };

            var sh = new SafeAction <T>((d) => send(d), null);

            return(TaskWrapper.Run(() => sh.SafeInvoke(data)));
        }
Beispiel #20
0
        public void OnBeginDrag(PointerEventData eventData)
        {
            Canvas canvas = LogicHandler.Canvas;

            if (canvas == null)
            {
                return;
            }

            m_last_drag_screen_pos = new Vector2(eventData.position.x, eventData.position.y);
            this.gameObject.transform.parent.transform.SetAsLastSibling();
            //this.gameObject.transform.parent.transform.localScale = new Vector3(1.05f, 1.05f, 1.0f);
            this.gameObject.transform.localScale = new Vector3(1.05f, 1.05f, 1.0f);
            m_canvas = canvas.transform as RectTransform;

            float limited_x = (eventData.position.x < limit_f ? limit_f : eventData.position.x);

            limited_x = (limited_x > Screen.width - limit_f ? Screen.width - limit_f : limited_x);

            float limited_y = (eventData.position.y < limit_f ? limit_f : eventData.position.y);

            limited_y = (limited_y > Screen.height - limit_f ? Screen.height - limit_f : limited_y);

            Vector2 limited_pos = new Vector2(limited_x, limited_y);

            Vector3 globalMousePos;

            if (RectTransformUtility.ScreenPointToWorldPointInRectangle(m_canvas, limited_pos, eventData.pressEventCamera, out globalMousePos))
            {
                m_begin_global_mouse_pos = globalMousePos;
                m_begin_pos = this.gameObject.transform.parent.transform.position;

                if (null != DragAbleMoveBegin)
                {
                    DragAbleMoveBegin.SafeInvoke(this.gameObject.transform.parent.gameObject);
                }
            }
        }
        private void LogMessageReceived( )
        {
            int sent = Interlocked.Increment(ref _receivedMessages);

            if (sent == 1)
            {
                _start = DateTime.Now;
            }

            if (Interlocked.CompareExchange(ref _receivedMessages, 0, Constants.MessagesLoggingThreshold) == Constants.MessagesLoggingThreshold)
            {
                DateTime now = DateTime.Now;

                TimeSpan elapsed = (now - _start);

                _start = now;

                var sh = new SafeAction <String>(s => Logger.LogInfo(s), Logger);

                TaskWrapper.Run(() => sh.SafeInvoke(
                                    String.Format("GatewayService received {0} events succesfully in {1} ms ", Constants.MessagesLoggingThreshold, elapsed.TotalMilliseconds.ToString( ))));
            }
        }
        public void Start(SensorEndpoint endpoint)
        {
            var sh = new SafeAction <SensorEndpoint>(e => RunSocketServer(e), _logger);

            TaskWrapper.Run(() => sh.SafeInvoke(endpoint));
        }
        public void Start( SensorEndpoint endpoint, int messagesToSend )
        {
            _messagesToSend = messagesToSend;
            _endpoint = endpoint;
            _doWorkSwitch = true;

            var sh = new SafeAction<int>( e => RunSocketAsClient( e ), _logger );

            TaskWrapper.Run( ( ) => sh.SafeInvoke( CONNECTION_RETRIES ) );
        }
Beispiel #24
0
        private void ThreadJob()
        {
            // signal that the worker thread has actually started processing the events
            _operational.Set();

            try
            {
                const int WAIT_TIMEOUT = 50; // milliseconds

                // run until Stop() is called
                while (_running == true)
                {
                    try
                    {
                        // If there are no tasks to be served, wait for some events to process
                        // Use a timeout to prevent race conditions on the outstanding tasks count
                        // and the actual queue count
                        _doWork.WaitOne(WAIT_TIMEOUT);

                        _logger.Flush();

                        // Fish from the queue and accumulate, keep track of outstanding tasks to
                        // avoid accumulating too many competing tasks. Note that we are going to schedule
                        // one more tasks than strictly needed, so that we prevent tasks to sit in the queue
                        // because of the race condition on the outstanding task count (_outstandingTasks)
                        // and the tasks actually sitting in the queue.  (*)
                        // To prevent this race condition, we will wait with a timeout
                        int count = _dataSource.Count - _outstandingTasks;

                        if (count == 0)
                        {
                            continue;
                        }

                        // check if we have been woken up to actually stop processing
                        EventBatchProcessedEventHandler eventBatchProcessed = null;

                        lock (_syncRoot)
                        {
                            if (_running == false)
                            {
                                return;
                            }

                            // take a snapshot of event handlers to invoke
                            eventBatchProcessed = OnEventsBatchProcessed;
                        }

                        // allocate a container to keep track of tasks for events in the queue
                        var tasks = new List <TaskWrapper>();

                        // process all messages that have not been processed yet
                        while (--count >= 0)
                        {
                            TaskWrapper <OperationStatus <TQueueItem> > t = null;

                            try
                            {
                                t = _dataSource.TryPop();
                            }
                            catch
                            {
                                Interlocked.Decrement(ref _outstandingTasks);

                                continue;
                            }

                            // increment outstanding task count
                            Interlocked.Increment(ref _outstandingTasks);

                            t.ContinueWith <TaskWrapper>(popped =>
                            {
                                // Decrement the numbers of outstanding tasks.
                                // (*) Note that there is a race  condition because at this point in time the tasks
                                // is already out of the queue but we did not decrement the outstanding task count
                                // yet. This race condition may cause tasks to be left sitting in the queue.
                                // To deal with this race condition, we will wait with a timeout
                                Interlocked.Decrement(ref _outstandingTasks);

                                // because the outstanding task counter is incremented before
                                // adding, we should never incur a negative count
                                Debug.Assert(_outstandingTasks >= 0);

                                if (popped?.Result != null && popped.Result.IsSuccess)
                                {
                                    return(_dataTarget.SendMessage(popped.Result.Result.GetDeviceId(), popped.Result.Result));
                                }

                                return(null);
                            });

                            AddToProcessed(tasks, t);
                        }

                        // alert any client about outstanding message tasks
                        if (eventBatchProcessed != null)
                        {
                            var sh = new SafeAction <List <TaskWrapper> >(allScheduledTasks => eventBatchProcessed(allScheduledTasks), Logger);

                            TaskWrapper.Run(() => sh.SafeInvoke(tasks));
                        }
                    }
                    catch (StackOverflowException ex) // do not hide stack overflow exceptions
                    {
                        Logger.LogError(_logMessagePrefix + ex.Message);
                        throw;
                    }
                    catch (OutOfMemoryException ex) // do not hide memory exceptions
                    {
                        Logger.LogError(_logMessagePrefix + ex.Message);
                        throw;
                    }
                    catch (Exception ex) // catch all other exceptions
                    {
                        Logger.LogError(_logMessagePrefix + ex.Message);
                    }
                }
            }
            finally
            {
                _operational.Set();
            }
        }
Beispiel #25
0
 public void OnPointerUp(UnityEngine.EventSystems.PointerEventData eventData)
 {
     //隐藏特效
     PointerUp.SafeInvoke();
 }
        public void Start( SensorEndpoint endpoint )
        {
            var sh = new SafeAction<SensorEndpoint>( e => RunSocketServer( e ), _logger );

            TaskWrapper.Run( ( ) => sh.SafeInvoke( endpoint ) );
        }
        protected virtual void DataInQueue( QueuedItem data )
        {
            DataInQueueEventHandler newData = OnDataInQueue;

            if( newData != null )
            {
                var sh = new SafeAction<QueuedItem>( d => newData( d ), Logger );

                TaskWrapper.Run( ( ) => sh.SafeInvoke( data ) );
            }

            //
            // NO logging on production code, enable for diagnostic purposes for debugging 
            //
#if DEBUG_LOG
            LogMessageReceived( );
#endif
        }
        private void LogMessageReceived( )
        {
            int sent = Interlocked.Increment( ref _receivedMessages );

            if( sent == 1 )
            {
                _start = DateTime.Now;
            }

            if( Interlocked.CompareExchange( ref _receivedMessages, 0, Constants.MessagesLoggingThreshold ) == Constants.MessagesLoggingThreshold )
            {
                DateTime now = DateTime.Now;

                TimeSpan elapsed = ( now - _start );

                _start = now;

                var sh = new SafeAction<String>( s => Logger.LogInfo( s ), Logger );

                TaskWrapper.Run( ( ) => sh.SafeInvoke(
                    String.Format( "GatewayService received {0} events succesfully in {1} ms ", Constants.MessagesLoggingThreshold, elapsed.TotalMilliseconds.ToString( ) ) ) );
            }
        }
Beispiel #29
0
 void OnToggleChecked(bool check_)
 {
     isCheck = check_;
     m_on_toggle_checked.SafeInvoke(check_, m_id);
 }
Beispiel #30
0
        // 支付成功处理函数;
        public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)
        {
            Debug.Log("Purchase OK: " + e.purchasedProduct.definition.id);

#if RECEIPT_VALIDATION // Local validation is available for GooglePlay, Apple, and UnityChannel stores
            if (m_IsGooglePlayStoreSelected ||
                //(m_IsUnityChannelSelected && m_FetchReceiptPayloadOnPurchase) ||
                Application.platform == RuntimePlatform.IPhonePlayer ||
                Application.platform == RuntimePlatform.OSXPlayer ||
                Application.platform == RuntimePlatform.tvOS)
            {
                try
                {
                    var result = validator.Validate(e.purchasedProduct.receipt);
                    Debug.Log("Receipt is valid. Contents:");
                    foreach (IPurchaseReceipt productReceipt in result)
                    {
                        Debug.Log("UNITY IAP productID : " + productReceipt.productID);
                        Debug.Log("UNITY IAP purchaseDate : " + productReceipt.purchaseDate);
                        Debug.Log("UNITY IAP transactionID : " + productReceipt.transactionID);

                        GooglePlayReceipt google = productReceipt as GooglePlayReceipt;
                        if (null != google)
                        {
                            Debug.Log(google.purchaseState);
                            Debug.Log(google.purchaseToken);
                        }

                        UnityChannelReceipt unityChannel = productReceipt as UnityChannelReceipt;
                        if (null != unityChannel)
                        {
                            Debug.Log(unityChannel.productID);
                            Debug.Log(unityChannel.purchaseDate);
                            Debug.Log(unityChannel.transactionID);
                        }

                        AppleInAppPurchaseReceipt apple = productReceipt as AppleInAppPurchaseReceipt;
                        if (null != apple)
                        {
                            Debug.Log("UNITY IAP originalTransactionIdentifier : " + apple.originalTransactionIdentifier);
                            Debug.Log("UNITY IAP subscriptionExpirationDate : " + apple.subscriptionExpirationDate);
                            Debug.Log("UNITY IAP cancellationDate : " + apple.cancellationDate);
                            Debug.Log("UNITY IAP quantity : " + apple.quantity);
                        }

                        // For improved security, consider comparing the signed
                        // IPurchaseReceipt.productId, IPurchaseReceipt.transactionID, and other data
                        // embedded in the signed receipt objects to the data which the game is using
                        // to make this purchase.
                    }
                }
                catch (IAPSecurityException ex)
                {
                    Debug.Log("Invalid receipt, not unlocking content. " + ex);
                    return(PurchaseProcessingResult.Complete);
                }
            }
#endif

            if (null != m_Usr_ReqVerifyTransaction)
            {
                m_Usr_ReqVerifyTransaction.SafeInvoke(e.purchasedProduct.definition.id, e.purchasedProduct.receipt);
            }
            else
            {
                return(PurchaseProcessingResult.Complete);
            }

            // 我们自己后台完毕的话,通过代码设置成功(如果是不需要后台设置直接设置完毕,不要设置Pending);
            return(PurchaseProcessingResult.Pending);
        }
Beispiel #31
0
 private void OnClicked(bool val)
 {
     m_mask.Visible = val;
     m_clicked_event.SafeInvoke(Officer_id, val);
 }
 private void OnClicked(GameObject obj_)
 {
     m_on_selected.SafeInvoke(m_info.OfficerId);
 }
Beispiel #33
0
        private void OnQuitClick(GameObject obj_)
        {
            CurViewLogic().OnQuit();

            m_OnQuit.SafeInvoke();
        }