Ejemplo n.º 1
0
            public bool TryRegister(Action <WindowMessageEventArgs> callback, out uint message)
            {
                message = 0;

                if (Callbacks.Count < ushort.MaxValue - MessageListener.BaseUserMessage)
                {
                    uint i = _lastMessage + 1;

                    while (i != _lastMessage)
                    {
                        if (i > ushort.MaxValue)
                        {
                            i = MessageListener.BaseUserMessage;
                        }

                        if (!Callbacks.ContainsKey(i))
                        {
                            _lastMessage = message = i;
                            Callbacks.Add(i, callback);
                            return(true);
                        }

                        i++;
                    }
                }

                return(false);
            }
Ejemplo n.º 2
0
 public void SetToastr(
     string title,
     string text,
     string type          = "Success",
     bool closeButton     = true,
     string positionClass = "toast-top-right",
     int showDuration     = 300,
     int hideDuration     = 300,
     int timeOut          = 5000,
     int extendedTimeout  = 1000,
     string showEasing    = "swing",
     string hideEasing    = "linear",
     string showMethod    = "fadeIn",
     string hideMethod    = "fadeOut")
 {
     Callbacks.Add(
         $"XGeneral.toastr{type}",
         new
     {
         title,
         text,
         closeButton,
         debug = false,
         positionClass,
         showDuration,
         hideDuration,
         timeOut,
         extendedTimeout,
         showEasing,
         hideEasing,
         showMethod,
         hideMethod
     });
 }
Ejemplo n.º 3
0
 public void On(string eventName, FunctionInstance fn)
 {
     Callbacks.Add(new EventCallback()
     {
         EventName = eventName, Callback = fn
     });
 }
Ejemplo n.º 4
0
        internal void AddCallback()
        {
            var callback = new Callback();

            Callbacks.Add(callback);
            SelectedCallback = callback;
        }
Ejemplo n.º 5
0
 public void SetHtml(string target, string message)
 {
     Callbacks.Add("XGeneral.Html", new
     {
         target,
         message
     });
 }
Ejemplo n.º 6
0
 public void SetRedirect(Uri url, object vars = null)
 {
     Callbacks.Add("XGeneral.redirect", new
     {
         url,
         vars
     });
 }
Ejemplo n.º 7
0
    public static void DrawPoint(Vector3 pos, float pixelsPerUnit = 1, float duration = 3)
    {
        var trans = Instantiate(t.debugSprite);

        trans.position   = pos;
        trans.localScale = new Vector3(1 / pixelsPerUnit, 1 / pixelsPerUnit, 1 / pixelsPerUnit);
        Callbacks.Add(() => Destroy(trans.gameObject), duration);
    }
Ejemplo n.º 8
0
 public void SetModalWithPartial(ModalType type, string path, string selector = null)
 {
     Callbacks.Add("XModal.initModal", new
     {
         type,
         selector = selector ?? $"#domModalGeneric{type}",
         path
     });
 }
        public void On <T>(Func <T, Task> callback)
        {
            if (!Callbacks.ContainsKey(typeof(T)))
            {
                Callbacks.Add(typeof(T), new List <MulticastDelegate>());
            }

            Callbacks[typeof(T)].Add(callback);
        }
        internal RegisterResult Register(string name, System.Delegate callback)
        {
            var thunk  = (name != "all")? CreateCallback(callback) : CreateGenericCallback(callback);
            var result = new RegisterResult {
                thunk = CallbackThunk, id = Callbacks.Count
            };

            Callbacks.Add(thunk);
            return(result);
        }
Ejemplo n.º 11
0
        public IDisposable OnReceived(Func <byte[], object, Task> callback, object state)
        {
            var receiveCallBack = new ReceiveCallback(callback, state);

            lock (Callbacks)
            {
                Callbacks.Add(receiveCallBack);
            }
            return(new Subscription(receiveCallBack, Callbacks));
        }
Ejemplo n.º 12
0
 public void SetPartial(Uri url, string target, object vars, string loadtext = "Actualizando...")
 {
     Callbacks.Add("XGeneral.renderpartial", new
     {
         url,
         target,
         loadtext,
         vars
     });
 }
Ejemplo n.º 13
0
    public void Confirm(Action <bool> onConfirm, bool left = true, bool once = true)
    {
        switch (inputDevice)
        {
#if SENSEGLOVE
        case InputDevice.SENSE_GLOVE:
        {
            onConfirmCallbacks.Add(onConfirm, once);

            if (coroutine == null)
            {
                dwellTimer.SetTimer(confirmationDwellTime, () =>
                    {
                        Debug.Log("UserInteractionManager, SenseGlove done");
                        StopCoroutine(coroutine);
                        coroutine = null;
                        Cleanup();
                        onConfirmCallbacks.Call(true);
                    });
                coroutine = StartCoroutine(SenseGloveConfirm(left));
            }
            break;
        }
#endif
        case InputDevice.CONTROLLERS:
            onConfirmCallbacks.Add(onConfirm, once);
            if (coroutine == null)
            {
                coroutine = StartCoroutine(ControllerConfirm());
            }
            break;

        case InputDevice.KEYBOARD:
        {
            onConfirmCallbacks.Add(onConfirm, once);
            if (coroutine == null)
            {
                coroutine = StartCoroutine(KeyboardConfirm());
            }
            break;
        }
        }
    }
Ejemplo n.º 14
0
        /// <summary>
        /// Constructor to create an EventDescriptor instance and set the meta-datas.
        /// </summary>
        public EventDescriptor(bool onlyOnce, bool autoDecodePayload, SocketIOCallback callback)
        {
            this.OnlyOnce          = onlyOnce;
            this.AutoDecodePayload = autoDecodePayload;
            this.Callbacks         = new List <SocketIOCallback>(1);

            if (callback != null)
            {
                Callbacks.Add(callback);
            }
        }
Ejemplo n.º 15
0
 public void SetGlitter(string title, string text, string className = "gritter-primary",
                        string beforeClose = "")
 {
     Callbacks.Add("XGeneral.gritter", new
     {
         title,
         text,
         class_name   = className,
         before_close = beforeClose
     });
 }
Ejemplo n.º 16
0
        public async Task SendMessageAsync(string method, object requestParams, Action <JToken> callBack)
        {
            var requestId = StringExtensions.RandomString;

            if (callBack != null)
            {
                Callbacks.Add(requestId, callBack);
            }
            await Websocket.SendAsync(PackMessage(method, requestId, requestParams), WebSocketMessageType.Text, true,
                                      CancellationToken.None);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Registers the member definitions.
        /// </summary>
        /// <param name="memberDefinitions">The member definitions.</param>
        private void RegisterMemberDefinitions(IEnumerable <IMemberDefinition> memberDefinitions)
        {
            lock (Callbacks)
            {
                InterceptedMembers = memberDefinitions.ToList();

                var members = InterceptedMembers.Where(member => !Callbacks.Contains(member));

                members.ForEach(member => Callbacks.Add(member, new CallbackCollection()));
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Adds the callback.
        /// </summary>
        /// <param name="callbackFunction">The callback function.</param>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        private Guid?AddCallback(CefV8Value callbackFunction, CefV8Context context)
        {
            if (callbackFunction != null && callbackFunction.IsFunction)
            {
                var callback = new JavascriptFunction(callbackFunction, context);
                Callbacks.Add(callback.Id, callback);

                return(callback.Id);
            }

            return(null);
        }
Ejemplo n.º 19
0
    public static void DrawPoints(IEnumerable <Vector2> points, Vector3 offset, float width, float height, float duration, float pixelsPerUnit = 1f)
    {
        List <Transform> transArr = new List <Transform>();

        points.ForEach(point =>
        {
            var trans      = Instantiate(t.debugSprite);
            trans.position = new Vector3(
                (point.x - width / 2) / pixelsPerUnit,
                (point.y - height / 2) / pixelsPerUnit, 0)
                             + offset
                             + new Vector3((1 / pixelsPerUnit) / 2, (1 / pixelsPerUnit) / 2, 0);
            trans.localScale = new Vector3(1 / pixelsPerUnit, 1 / pixelsPerUnit, 1 / pixelsPerUnit);
            transArr.Add(trans);
        });
        Callbacks.Add(() => transArr.ForEach(trans => Destroy(trans.gameObject)), duration);
    }
 public void RegisterForCallback()
 {
     try
     {
         Client clientCallback = OpContext.GetCallbackChannel();
         Debug.Assert(clientCallback != null);
         lock (CallbackLock)
         {
             if (!Callbacks.Contains(clientCallback))
             {
                 Log.Debug("Callback registration.");
                 Callbacks.Add(clientCallback);
             }
         }
     }
     catch (Exception e) { throw GetFault(e); }
 }
Ejemplo n.º 21
0
        public Guid On <T>(Action <T> callback)
        {
            lock (Callbacks) {
                if (!Callbacks.ContainsKey(typeof(T)))
                {
                    Callbacks.Add(typeof(T), new Dictionary <Guid, MulticastDelegate>());
                }

                var id = Guid.NewGuid();
                Callbacks[typeof(T)].Add(id, callback);

                lock (CallbackTypes) {
                    CallbackTypes.Add(id, typeof(T));
                }

                return(id);
            }
        }
Ejemplo n.º 22
0
		/*
		 * BeginProcessRequest gets called automatically when the request comes in
		 * We don't have to handle things in ProcessRequest/PageLoad and then set 
		 * everything up manually using RegisterAsyncTask like we do with an async
		 * aspx page. We ignore 
		 */
		public IAsyncResult BeginProcessRequest( HttpContext context, AsyncCallback callback, Object extraData ) {
			context.Response.Write( "<p>BeginProcessReqeust: Thread " + Thread.CurrentThread.ManagedThreadId + "</p>" );
			
			// async is a dummy IAsyncResult to satisfy the method signature
			AsyncOperation async = new AsyncOperation( null, null, null );

			// Callback context holds a callback and the httpcontext.
			// In hindsight we could have done this without the callback
			// so this is a possible point of refactoring. (TODO)
			CallbackContext callbackContext = new CallbackContext( 
				new NotificationCallback( Callback ), 
				context
			);

			/**
			 * TODO: this is too coarse of a lock, should be locking 'callbacks'
			 */
			lock( typeof( Register ) ) {
				Callbacks.Add( Guid.NewGuid().ToString(), callbackContext );
			}
			return async;
		}
Ejemplo n.º 23
0
        private Guid?AddCallback(CefV8Value callbackFunction, CefV8Context context)
        {
            if (callbackFunction != null)
            {
                if (context == null)
                {
                    throw new ArgumentNullException("context");
                }

                if (!callbackFunction.IsFunction)
                {
                    throw new ArgumentException("Not a function.", "callbackFunction");
                }

                var callback = new JavascriptFunction(callbackFunction, context);
                Callbacks.Add(callback.Id, callback);

                return(callback.Id);
            }

            return(null);
        }
Ejemplo n.º 24
0
 public virtual void OnMessageReceived(Func <IModel, BasicDeliverEventArgs, Task> callback)
 {
     Callbacks.Add(callback);
 }
Ejemplo n.º 25
0
 public virtual void OnMessageReceived(Func <Message <string, byte[]>, Task> callback)
 {
     Callbacks.Add(callback);
 }
Ejemplo n.º 26
0
 // Start is called before the first frame update
 void Start()
 {
     Callbacks.Add(() => Debug.Log("Ran!"), 3);
     Destroy(gameObject);
 }
Ejemplo n.º 27
0
 public bool AddCallback(TaskCompletionSource <Ice.IObjectPrx> cb)
 {
     Callbacks.Add(cb);
     return(Callbacks.Count == 1);
 }
Ejemplo n.º 28
0
 private void OnLoginWithCustomId(LoginWithCustomIDRequest request)
 {
     Callbacks.Add("OnRequest_InstLogin");
 }
Ejemplo n.º 29
0
 private void OnLoginResult(LoginResult result)
 {
     Callbacks.Add("OnResponse_InstLogin");
 }
Ejemplo n.º 30
0
 public void TriggerEnterCallback(System.Action <Vector3> callback, bool once = false) => onTriggerEnter.Add(callback, once);