/// <summary>
        /// FromOperation - Sends a notification
        /// </summary>
        /// <param name="operation"></param>
        /// <returns></returns>
        public static HttpNotification FromOperation(DsspOperation operation)
        {
            HttpNotification notification = new HttpNotification();

            notification._operation = operation.GetType().Name;

            if (operation.Body is FlexButton)
            {
                notification._button = operation.Body as FlexButton;
            }
            else if (operation.Body is FlexControl)
            {
                notification._control = operation.Body as FlexControl;
            }
            else if (operation.Body is ShowRequest)
            {
                notification._show = operation.Body as ShowRequest;
            }
            else if (operation.Body is ButtonPressRequest)
            {
                notification._buttonPress = operation.Body as ButtonPressRequest;
            }
            else if (operation.Body is SetTitleRequest)
            {
                notification._setTitle = operation.Body as SetTitleRequest;
            }
            else if (operation.Body is HandOffMessage)
            {
                notification._handOff = operation.Body as HandOffMessage;
            }

            return(notification);
        }
Exemplo n.º 2
0
        public void OnHttpQuery(HttpQuery query)
        {
            string session = query.Body.Query["Session"];

            if (string.IsNullOrEmpty(session))
            {
                query.ResponsePort.Post(new HttpResponseType(HttpStatusCode.OK, _state, _transform));
                return;
            }

            if (!_waitingNotifications.ContainsKey(session))
            {
                _waitingNotifications.Add(session, new Queue <DsspOperation>());
            }

            Queue <DsspOperation> queue = _waitingNotifications[session];
            HttpNotification      notification;

            if (queue.Count == 0)
            {
                notification           = new HttpNotification();
                notification.Operation = "None";
            }
            else
            {
                DsspOperation operation = queue.Dequeue();
                notification = HttpNotification.FromOperation(operation);
            }

            query.ResponsePort.Post(new HttpResponseType(notification));
        }