コード例 #1
0
        private void ReceivedPublish(MqttMessage.Publish message)
        {
            JObject payload      = StringToJObject(message.Payload);
            var     aloxiMessage = AloxiMessage.Build(message.Operation, payload, message.ResponseTopic);

            PublishAloxiMessage(aloxiMessage, message.Topic);
        }
コード例 #2
0
        private void ReceivedPublishAlexaResponse(MqttMessage.PublishAlexaResponse message)
        {
            JObject payload      = StringToJObject(message.SerializedResponse);
            var     aloxiMessage = AloxiMessage.Build(AloxiMessageOperation.PipeAlexaResponse, payload);

            PublishAloxiMessage(aloxiMessage, this.alexaResponseTopic);
        }
コード例 #3
0
        public Task <TResponsePayload> RequestBridge <TResponsePayload>(AloxiMessageOperation operation, object requestPayload) where TResponsePayload : class
        {
            var requestMessage = AloxiMessage.Build(operation, Pack(requestPayload), this.configuration.TopicResponse);

            return(PublishAndAwaitResponse(configuration.TopicBridge, requestMessage)
                   .ContinueWith <TResponsePayload>((publishTask) =>
            {
                var responseMessage = publishTask.Result;
                if (responseMessage == null)
                {
                    return null;
                }
                return UnpackTo <TResponsePayload>(responseMessage.Data);
            }));
        }
コード例 #4
0
        public Task <JObject> RequestBridgePassthrough(AloxiMessageOperation operation, JObject payload)
        {
            var requestMessage = AloxiMessage.Build(operation, payload, this.configuration.TopicResponse);

            Log.Debug(this.lambdaContext, $"PSC/RBP: Publishing AloxiMessage '{operation}' and waiting for response");
            return(PublishAndAwaitResponse(configuration.TopicBridge, requestMessage)
                   .ContinueWith <JObject>((publishTask) =>
            {
                if (publishTask.Result == null)
                {
                    Log.Warn(this.lambdaContext, $"PSC/RBP: Passing NULL through (we did not get a response?)");
                    return null;
                }
                Log.Debug(this.lambdaContext, $"PSC/RBP: Continueing with {publishTask?.Result?.Data?.Count} datanodes");
                return publishTask.Result.Data;
            }));
        }