Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="eventType"></param>
        /// <param name="eventHandler"></param>
        /// <returns></returns>
        public Task AddEventListenerAsync(FDC3EventType eventType, Action <FDC3Event> eventHandler)
        {
            var hasAny = FDC3Handlers.HasEventListener(this.ChannelId);

            FDC3Handlers.FDC3ChannelEventHandlers[this.ChannelId].Add(eventType, eventHandler);

            if (!hasAny)
            {
                return(connection.AddChannelEventListenerAsync(this.ChannelId, eventType));
            }
            else
            {
                return(new TaskCompletionSource <object>(null).Task);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the event that is fired when a window broadcasts on this channel
        /// </summary>
        /// <param name="listener"></param>
        /// <returns></returns>
        public Task AddContextListenerAsync(Action <ContextBase> listener)
        {
            var channelContextListener = new ChannelContextListener
            {
                Channel = this,
                Handler = listener
            };

            var hasAny = FDC3Handlers.HasContextListener(this.ChannelId);

            FDC3Handlers.ChannelContextHandlers.Add(channelContextListener);

            if (!hasAny)
            {
                return(connection.AddChannelContextListenerAsync(this.ChannelId));
            }
            else
            {
                return(new TaskCompletionSource <object>(null).Task);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Ads a listener for incoming intents from the agent
        /// </summary>
        /// <param name="intent">The intent to listen for</param>
        /// <param name="handler">The handler to be called when an intent in received</param>
        public Task AddIntentListenerAsync(string intent, Action <ContextBase> handler)
        {
            var hasIntent = FDC3Handlers.HasIntentHandler(intent);

            if (FDC3Handlers.IntentHandlers.Any(x => x.Key == intent))
            {
                FDC3Handlers.IntentHandlers[intent] += handler;
            }
            else
            {
                FDC3Handlers.IntentHandlers.Add(intent, handler);
            }

            if (!hasIntent)
            {
                return(channelClient.DispatchAsync(ApiFromClientTopic.AddIntentListener, new { intent }));;
            }
            else
            {
                return(Task.FromResult <object>(null));
            }
        }