Ejemplo n.º 1
0
 public ServiceCommunication(IStateMachineHost host,
                             Uri?target,
                             Uri type,
                             InvokeId invokeId)
 {
     _host     = host;
     _target   = target;
     _type     = type;
     _invokeId = invokeId;
 }
Ejemplo n.º 2
0
        public virtual ValueTask Cancel(InvokeId invokeId, IExecutionContext executionContext, CancellationToken token)
        {
            if (executionContext is null)
            {
                throw new ArgumentNullException(nameof(executionContext));
            }
            if (invokeId is null)
            {
                throw new ArgumentNullException(nameof(invokeId));
            }

            return(executionContext.CancelInvoke(invokeId, token));
        }
        async ValueTask IExternalCommunication.CancelInvoke(InvokeId invokeId, CancellationToken token)
        {
            try
            {
                if (_options.ExternalCommunication is not {
                } externalCommunication)
                {
                    throw NoExternalCommunication();
                }

                await externalCommunication.CancelInvoke(invokeId, token).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                throw new CommunicationException(ex, _sessionId);
            }
        }
        private async ValueTask ForwardEvent(IEvent evt, InvokeId invokeId, CancellationToken token)
        {
            try
            {
                if (_options.ExternalCommunication is not {
                } externalCommunication)
                {
                    throw NoExternalCommunication();
                }

                await externalCommunication.ForwardEvent(evt, invokeId, token).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                throw new CommunicationException(ex, _sessionId);
            }
        }
Ejemplo n.º 5
0
        public virtual async ValueTask <InvokeId> Start(IIdentifier stateId, IExecutionContext executionContext, CancellationToken token)
        {
            if (stateId is null)
            {
                throw new ArgumentNullException(nameof(stateId));
            }
            if (executionContext is null)
            {
                throw new ArgumentNullException(nameof(executionContext));
            }

            var invokeId = InvokeId.New(stateId, _invoke.Id);

            if (IdLocationEvaluator is not null)
            {
                await IdLocationEvaluator.SetValue(invokeId, executionContext, token).ConfigureAwait(false);
            }

            var type = TypeExpressionEvaluator is not null?ToUri(await TypeExpressionEvaluator.EvaluateString(executionContext, token).ConfigureAwait(false)) : _invoke.Type;

            var source = SourceExpressionEvaluator is not null?ToUri(await SourceExpressionEvaluator.EvaluateString(executionContext, token).ConfigureAwait(false)) : _invoke.Source;

            var rawContent = ContentBodyEvaluator is IStringEvaluator rawContentEvaluator ? await rawContentEvaluator.EvaluateString(executionContext, token).ConfigureAwait(false) : null;

            var content = await DataConverter.GetContent(ContentBodyEvaluator, ContentExpressionEvaluator, executionContext, token).ConfigureAwait(false);

            var parameters = await DataConverter.GetParameters(NameEvaluatorList, ParameterList, executionContext, token).ConfigureAwait(false);

            Infra.NotNull(type);

            var invokeData = new InvokeData(invokeId, type)
            {
                Source     = source,
                RawContent = rawContent,
                Content    = content,
                Parameters = parameters
            };

            await executionContext.StartInvoke(invokeData, token).ConfigureAwait(false);

            return(invokeId);
        }
Ejemplo n.º 6
0
    private void OnHttpError(string errorMessage)
    {
        if (!(this.taskId is null))
        {
            this.executer.StopExecute(this.taskId);
        }

        errorText.text = errorMessage;

        errorText.GetComponent <CanvasRenderer>().SetAlpha(0);

        var colorToFadeTo = new Color(1f, 1f, 1f, 1);

        errorText.CrossFadeColor(colorToFadeTo, 0.2f, true, true);

        this.taskId = this.executer.DelayExecute(10, x => {
            colorToFadeTo = new Color(1f, 1f, 1f, 0);
            errorText.CrossFadeColor(colorToFadeTo, 0.2f, true, true);
        });
    }
 ValueTask IExternalCommunication.ForwardEvent(IEvent evt, InvokeId invokeId, CancellationToken token) => ForwardEvent(evt, invokeId, token);