Esempio n. 1
0
        public async Task <InvokeRoutineResult> InvokeAsync(
            MethodInvocationData data,
            InvocationPreferences preferences)
        {
            var message = new Message
            {
                Type = MessageType.InvokeMethod,
            };

            MethodInvocationDataTransformer.Write(message, data, _serializer);

            var result = new InvokeRoutineResult
            {
                Outcome = InvocationOutcome.Scheduled
            };

            if (preferences.Synchronous)
            {
                var completionNotification = new TaskCompletionSource <InvokeRoutineResult>();
                message.Data["Notification"] = completionNotification;

                _messageHub.Schedule(message);

                result = await completionNotification.Task;

                if (result.Result != null)
                {
                    result.Result = TaskResult.CreateEmpty(preferences.ResultValueType);
                    _serializer.Populate(_serializer.SerializeToString(result.Result), (IValueContainer)result.Result);
                }
            }
            else if (preferences.LockMessage)
            {
                result.MessageHandle = new MessageHandle(message, _messageHub);
            }
            else
            {
                _messageHub.Schedule(message);
            }

            return(result);
        }
Esempio n. 2
0
        public void ReleaseLock()
        {
            if (_messageHub == null || _message == null)
            {
                return;
            }

            _messageHub.Schedule(_message);
            _message    = null;
            _messageHub = null;
        }
Esempio n. 3
0
        public Task PublishAsync(EventPublishData data, PublishPreferences preferences)
        {
            var message = new Message
            {
                Type = MessageType.Event,
            };

            EventPublishDataTransformer.Write(message, data, preferences, _serializer);

            _messageHub.Schedule(message);

            return(Task.CompletedTask);
        }