Exemplo n.º 1
0
            public static KeepCallback KeepGetMessage(Action <ReturnValue <KFCallMsg> > _onReturn_)
            {
                Callback <ReturnValue <KfCall._p21> > _onOutput_ = KfCall.TcpClient.GetCallback <KFCallMsg, KfCall._p21>(_onReturn_);

                try
                {
                    AutoCSer.Net.TcpInternalServer.ClientSocketSender _socket_ = KfCall.TcpClient.Sender;
                    if (_socket_ != null)
                    {
                        return(_socket_.GetKeep <KfCall._p21>(TcpCall.KFServiceBase._ac14, ref _onOutput_));
                    }
                }
                finally
                {
                    if (_onOutput_ != null)
                    {
                        ReturnValue <KfCall._p21> _outputParameter_ = new ReturnValue <KfCall._p21>
                        {
                            Type = ReturnType.ClientException
                        };
                        _onOutput_.Call(ref _outputParameter_);
                    }
                }
                return(null);
            }
Exemplo n.º 2
0
 public override void SetEventListener(string eventName, Callback fun)
 {
     if (eventName == "onGUI")
     {
         Element.onGUIHandler = () => fun?.Call(this);
     }
     else
     {
         base.SetEventListener(eventName, fun);
     }
 }
Exemplo n.º 3
0
        private void onReceive()
        {
            Callback <ReturnValue <outputParameterType> > callback = Callback;
            ClientSocket socket = Socket;
            ReturnValue <outputParameterType> outputParameter = OutputParameter;

            Callback = null;
            Socket   = null;
            OutputParameter.Value = default(outputParameterType);
            AutoCSer.Threading.RingPool <OutputCommand <outputParameterType> > .Default.PushNotNull(this);

            callback.Call(ref outputParameter);
        }
Exemplo n.º 4
0
        public override void SetEventListener(string eventName, Callback callback)
        {
            switch (eventName)
            {
            case "onClick":
                Button.onClick.RemoveAllListeners();
                if (callback != null)
                {
                    Button.onClick.AddListener(new UnityAction(() => callback.Call(null)));
                }
                return;

            default:
                base.SetEventListener(eventName, callback);
                return;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 回调处理
        /// </summary>
        private void onReceive()
        {
            Callback <ReturnValue <outputParameterType> > callback = Callback;

            if (callback != null)
            {
                Monitor.Enter(OutputLock);
                do
                {
                    currentOutputParameters.Exchange(ref outputParameters);
                    Monitor.Exit(OutputLock);
                    ReturnValue <outputParameterType>[] outputParameterArray = currentOutputParameters.Array;
                    int index = 0, count = currentOutputParameters.Length;
                    do
                    {
                        try
                        {
                            do
                            {
                                callback.Call(ref outputParameterArray[index]);
                            }while (++index != count);
                            break;
                        }
                        catch (Exception error)
                        {
                            Socket.Log.Add(AutoCSer.Log.LogType.Error, error);
                        }
                    }while (++index != count);
                    if (AutoCSer.DynamicArray <outputParameterType> .IsClearArray)
                    {
                        System.Array.Clear(outputParameterArray, 0, count);
                    }
                    currentOutputParameters.Length = 0;

                    Monitor.Enter(OutputLock);
                    if (outputParameters.Length == 0)
                    {
                        isOutput = 0;
                        Monitor.Exit(OutputLock);
                        return;
                    }
                }while (true);
            }
        }
Exemplo n.º 6
0
        private void onReceive()
        {
            Callback <ReturnValue <outputParameterType> > callback = Callback;
            ClientSocket socket = Socket;
            ReturnValue <outputParameterType> outputParameter = OutputParameter;

            Callback = null;
            Socket   = null;
            OutputParameter.Value = default(outputParameterType);
            AutoCSer.Threading.RingPool <OutputCommand <outputParameterType> > .Default.PushNotNull(this);

            try
            {
                callback.Call(ref outputParameter);
            }
            catch (Exception error)
            {
                socket.Log.Add(AutoCSer.Log.LogType.Error, error);
            }
        }
Exemplo n.º 7
0
        void SetCamera(Camera camera)
        {
            if (currentCamera == camera)
            {
                return;
            }

            if (currentCamera)
            {
                onUnmount?.Call(currentCamera, this);
                currentCamera = null;
            }

            currentCamera = camera;

            if (currentCamera)
            {
                onMount?.Call(currentCamera, this);
            }
        }
Exemplo n.º 8
0
        public override void SetEventListener(string eventName, Callback callback)
        {
            switch (eventName)
            {
            case "onButtonClick":
                if (previousClickEvent != null)
                {
                    Element.clicked   -= previousClickEvent;
                    previousClickEvent = null;
                }
                if (callback != null)
                {
                    Element.clicked += (previousClickEvent = () => callback.Call(this));
                }
                return;

            default:
                base.SetEventListener(eventName, callback);
                return;
            }
        }
Exemplo n.º 9
0
 public void Invoke()
 {
     lock (Lock)
     {
         Invoking = true;
         Callback callback = First;
         while (callback != null)
         {
             callback.Call();
             callback = callback.Next;
         }
         Invoking = false;
         Queue <Callback> removedQueue = RemovedQueue;
         while (removedQueue.Count > 0)
         {
             callback          = removedQueue.Dequeue();
             callback.Previous = null;
             callback.Next     = null;
         }
     }
 }
Exemplo n.º 10
0
        void SetCamera(Camera camera)
        {
            if (currentCamera == camera)
            {
                return;
            }

            if (currentCamera)
            {
                currentCamera.targetTexture = null;
                onUnmount?.Call(currentCamera, this);
                currentCamera = null;
            }

            currentCamera = camera;

            if (currentCamera)
            {
                currentCamera.targetTexture = RenderTexture;
                onMount?.Call(currentCamera, this);
            }
        }
Exemplo n.º 11
0
        private void onReceive()
        {
            Callback <TcpServer.ReturnValue <outputParameterType> > callback = Callback;
            ClientSocket socket = Socket;

            TcpServer.ReturnValue <outputParameterType> outputParameter = OutputParameter;
            Callback = null;
            Socket   = null;
            OutputParameter.Value = default(outputParameterType);
            if ((Interlocked.Increment(ref FreeLock) & 1) == 0)
            {
                free();
            }
            try
            {
                callback.Call(ref outputParameter);
            }
            catch (Exception error)
            {
                socket.Log.add(AutoCSer.Log.LogType.Error, error);
            }
        }
Exemplo n.º 12
0
        public ActionResult CallbackAction()
        {
            // Ziskani parametru z redirektu po potvrzeni / zruseni platby
            long   returnedPaymentSessionId   = 0;
            long   returnedGoId               = 0;
            string returnedOrderNumber        = "";
            string returnedEncryptedSignature = "";

            if (null != Request.QueryString.Get("paymentSessionId"))
            {
                returnedPaymentSessionId = long.Parse(Request.QueryString.Get("paymentSessionId"));
            }

            if (null != Request.QueryString.Get("targetGoId"))
            {
                returnedGoId = long.Parse(Request.QueryString.Get("targetGoId"));
            }

            if (null != Request.QueryString.Get("orderNumber"))
            {
                returnedOrderNumber = Request.QueryString.Get("orderNumber");
            }

            if (null != Request.QueryString.Get("encryptedSignature"))
            {
                returnedEncryptedSignature = Request.QueryString.Get("encryptedSignature");
            }

            Callback callback = new Callback();

            string redirectUrl = callback.Call(
                returnedGoId,
                returnedPaymentSessionId,
                returnedOrderNumber,
                returnedEncryptedSignature
                );

            return(Redirect(redirectUrl));
        }
Exemplo n.º 13
0
        public virtual void SetEventListener(string eventName, Callback fun)
        {
            var(register, unregister) = EditorEventHandlerMap.GetEventMethods(eventName);

            // Remove
            if (EventHandlers.TryGetValue(eventName, out var existingHandler))
            {
                unregister.Invoke(Element, new object[] { existingHandler, TrickleDown.NoTrickleDown });
                EventHandlers.Remove(eventName);
            }

            // No event to add
            if (fun == null)
            {
                return;
            }

            EventCallback <EventBase> callAction = (e) => fun.Call(e, this);

            register.Invoke(Element, new object[] { callAction, TrickleDown.NoTrickleDown });
            EventHandlers[eventName] = callAction;
        }
Exemplo n.º 14
0
 public int setTimeout(Callback callback, int timeout)
 {
     return(MainThreadDispatcher.Timeout(() => callback.Call(), timeout / 1000f));
 }
Exemplo n.º 15
0
 public int requestAnimationFrame(Callback callback)
 {
     return(MainThreadDispatcher.AnimationFrame(() => callback.Call()));
 }
Exemplo n.º 16
0
 public int setImmediate(Callback callback)
 {
     return(MainThreadDispatcher.Immediate(() => callback.Call()));
 }
Exemplo n.º 17
0
        /// <summary>
        /// 接收数据回调处理
        /// </summary>
        /// <param name="data">输出数据</param>
        internal override void OnReceive(ref SubArray <byte> data)
        {
            Callback <ReturnValue <outputParameterType> > callback = Callback;

            if (callback != null)
            {
                ReturnValue <outputParameterType> outputParameter = new ReturnValue <outputParameterType>();
                if (CommandInfo.TaskType == ClientTaskType.Synchronous)
                {
                    try
                    {
                        onReceive(ref data, ref outputParameter);
                    }
                    catch (Exception error)
                    {
                        Socket.Log.Add(AutoCSer.Log.LogType.Error, error);
                    }
                    finally { callback.Call(ref outputParameter); }
                }
                else
                {
                    try
                    {
                        onReceive(ref data, ref outputParameter);
                    }
                    catch (Exception error)
                    {
                        outputParameter.Type  = ReturnType.ClientException;
                        outputParameter.Value = default(outputParameterType);
                        Socket.Log.Add(AutoCSer.Log.LogType.Error, error);
                    }
                    int isOutput = 1;
                    Monitor.Enter(OutputLock);
                    try
                    {
                        outputParameters.Add(outputParameter);
                        isOutput      = this.isOutput;
                        this.isOutput = 1;
                    }
                    catch (Exception error)
                    {
                        Socket.Log.Add(AutoCSer.Log.LogType.Error, error);
                    }
                    finally { Monitor.Exit(OutputLock); }
                    if (isOutput == 0)
                    {
                        switch (CommandInfo.TaskType)
                        {
                        case ClientTaskType.ThreadPool: if (!System.Threading.ThreadPool.QueueUserWorkItem(threadPoolOnReceive))
                            {
                                AutoCSer.Threading.LinkTask.Task.Add(this);
                            }
                            return;

                        case ClientTaskType.Timeout: AutoCSer.Threading.LinkTask.Task.Add(this); return;

                        case ClientTaskType.TcpTask: ClientCallTask.Task.Add(this); return;

                        case ClientTaskType.TcpQueue: ClientCallQueue.Default.Add(this); return;
                        }
                    }
                }
            }
        }
Exemplo n.º 18
0
        public override void SetEventListener(string eventName, Callback callback)
        {
            switch (eventName)
            {
            case "onChange":
                if (previousChangeEvent != null)
                {
                    Element.UnregisterValueChangedCallback(previousChangeEvent);
                    previousChangeEvent = null;
                }
                if (callback != null)
                {
                    Element.RegisterValueChangedCallback(previousChangeEvent = (ev) => callback.Call(ev, this));
                }
                return;

            default:
                base.SetEventListener(eventName, callback);
                return;
            }
        }
Exemplo n.º 19
0
 public int setInterval(Callback callback, int timeout)
 {
     return(MainThreadDispatcher.Interval(() => callback.Call(), timeout / 1000f));
 }
Exemplo n.º 20
0
        /// <summary>
        /// 接收数据回调处理
        /// </summary>
        /// <param name="data">输出数据</param>
        internal override void OnReceive(ref SubArray <byte> data)
        {
            Callback <ReturnValue <outputParameterType> > callback = Callback;

            if (callback != null)
            {
                ReturnValue <outputParameterType> outputParameter = new ReturnValue <outputParameterType>();
                if (CommandInfo.TaskType == ClientTaskType.Synchronous)
                {
                    try
                    {
                        onReceive(ref data, ref outputParameter);
                    }
                    catch (Exception error)
                    {
                        Socket.Log.Exception(error, null, LogLevel.Exception | LogLevel.AutoCSer);
                    }
                    finally { callback.Call(ref outputParameter); }
                }
                else
                {
                    try
                    {
                        onReceive(ref data, ref outputParameter);
                    }
                    catch (Exception error)
                    {
                        outputParameter.Type  = ReturnType.ClientException;
                        outputParameter.Value = default(outputParameterType);
                        Socket.Log.Exception(error, null, LogLevel.Exception | LogLevel.AutoCSer);
                    }
                    int       isOutput  = 1;
                    Exception exception = null;
                    OutputLock.Enter();
                    try
                    {
                        if (outputParameters.FreeCount == 0)
                        {
                            OutputLock.SleepFlag = 1;
                        }
                        outputParameters.Add(outputParameter);
                        isOutput      = this.isOutput;
                        this.isOutput = 1;
                    }
                    catch (Exception error) { exception = error; }
                    finally
                    {
                        OutputLock.ExitSleepFlag();
                        if (exception != null)
                        {
                            Socket.Log.Exception(exception, null, LogLevel.Exception | LogLevel.AutoCSer);
                        }
                    }
                    if (isOutput == 0)
                    {
                        switch (CommandInfo.TaskType)
                        {
                        case ClientTaskType.ThreadPool: if (!System.Threading.ThreadPool.QueueUserWorkItem(threadPoolOnReceive))
                            {
                                AutoCSer.Threading.TaskSwitchThreadArray.Default.CurrentThread.Add(this);
                            }
                            return;

                        case ClientTaskType.Timeout: AutoCSer.Threading.TaskSwitchThreadArray.Default.CurrentThread.Add(this); return;

                        case ClientTaskType.TcpTask: ClientCallThreadArray.Default.CurrentThread.Add(this); return;

                        case ClientTaskType.TcpQueue: ClientCallQueue.Default.Add(this); return;
                        }
                    }
                }
            }
        }