private void SendButtonPress(object sender, bool pressed)
        {
            Button button = sender as Button;

            if (button == null)
            {
                return;
            }

            ButtonPress press = new ButtonPress();

            press.Body.Id      = button.Name;
            press.Body.Pressed = pressed;
            _mainPort.Post(press);
        }
Beispiel #2
0
        public IEnumerator <ITask> OnHandOff(HandOff handOff)
        {
            Fault fault = null;

            ServiceInfoType[] services = null;

            dir.QueryRequestType request = new dir.QueryRequestType(
                new ServiceInfoType(Contract.Identifier)
                );
            dir.Query query = new dir.Query(request);
            query.TimeSpan = new TimeSpan(0, 0, 2);
            DirectoryPort.Post(query);

            yield return(Arbiter.Choice(
                             query.ResponsePort,
                             delegate(dir.QueryResponseType success)
            {
                services = success.RecordList;
            },
                             delegate(Fault f)
            {
                fault = f;
            }
                             ));

            if (fault != null)
            {
                handOff.ResponsePort.Post(fault);
                yield break;
            }

            foreach (ServiceInfoType service in services)
            {
                FlexDialogOperations fwd   = ServiceForwarder <FlexDialogOperations>(service.Service);
                FlexDialogState      state = null;

                Get get = new Get();
                get.TimeSpan = new TimeSpan(0, 0, 2);
                fwd.Post(get);

                yield return(Arbiter.Choice(
                                 get.ResponsePort,
                                 delegate(FlexDialogState success)
                {
                    state = success;
                },
                                 delegate(Fault f)
                {
                    fault = f;
                }
                                 ));

                if (state != null && state.Title == handOff.Body.Title)
                {
                    handOff.Body.Service = service.HttpServiceAlias.ToString();
                    DoSendNotification(handOff);
                    handOff.ResponsePort.Post(handOff.Body);
                    yield break;
                }
            }

            handOff.ResponsePort.Post(
                Fault.FromCodeSubcodeReason(
                    FaultCodes.Receiver,
                    DsspFaultCodes.UnknownEntry,
                    "Unable to find dialog with title: " + handOff.Body.Title
                    )
                );
        }