Beispiel #1
0
        public Task Stop()
        {
            if (_currentState is State.StoppableState)
            {
                IObservable <Unit> observable = ObservableExtentions.Either(
                    _messageMediator.GetEvent <Messages.IStoppedMessage>().Timeout(TimeSpan.FromSeconds(10)),
                    _messageMediator.GetEvent <Messages.IErrorMessage>(),
                    (started, error) =>
                {
                    if (error != null)
                    {
                        throw new ApplicationException("Error stopping Harmony", error.Exception);
                    }
                    else
                    {
                        return(Unit.Default);
                    }
                }
                    );


                Task result = observable.ToTask();

                _messageMediator.Publish(new Messages.StopHarmonizingMessage());

                return(result);
            }
            else
            {
                return(Task.FromResult <object>(null));
            }
        }
Beispiel #2
0
        public Task Start()
        {
            IObservable <Unit> observable = ObservableExtentions.Either(
                _eventMediator.GetEvent <Gateway.Event.Started>().Timeout(TimeSpan.FromSeconds(30)),
                _eventMediator.GetEvent <Gateway.Event.Errored>(),
                (started, error) =>
            {
                if (error != null)
                {
                    throw new ApplicationException("Error starting Owl", error.Exception);
                }
                else
                {
                    return(Unit.Default);
                }
            }
                );

            Task result = observable.ToTask();

            _eventMediator.Publish(new Event.Connect());

            return(Task.FromResult <object>(null));
        }
Beispiel #3
0
        public Task Start()
        {
            IObservable <Unit> observable = ObservableExtentions.Either(
                _messageMediator.GetEvent <Messages.IStartedMessage>().Timeout(TimeSpan.FromSeconds(30)),
                _messageMediator.GetEvent <Messages.IErrorMessage>(),
                (started, error) =>
            {
                if (error != null)
                {
                    throw new ApplicationException("Error starting Harmony", error.Exception);
                }
                else
                {
                    return(Unit.Default);
                }
            }
                );

            Task result = observable.Take(1).ToTask();

            _messageMediator.Publish(new Messages.StartHarmonizingMessage());

            return(result);
        }