Exemplo n.º 1
0
 private void ReceivedProcess(MqttMessage.Process message)
 {
     if (message.Operation == AloxiMessageOperation.Echo)
     {
         this.publisher.Tell(new MqttMessage.Publish(message.ResponseTopic, AloxiMessageOperation.EchoResponse, message.Payload));
     }
 }
Exemplo n.º 2
0
        private void ReceivedProcess(MqttMessage.Process message)
        {
            if (message.Operation != AloxiMessageOperation.PipeAlexaRequest)
            {
                log.Error("Got non-compatible Aloxi operation: {0}", message.Operation);
                return;
            }
            var request = JsonConvert.DeserializeObject <AlexaSmartHomeRequest>(message.Payload, this.jsonSettings);

            if (request.Directive.Header.Namespace == NS_DISCOVERY)
            {
                ProcessDiscovery(request.Directive.Header.Name, request.Directive);
            }
            else if (request.Directive.Header.Namespace == NS_POWERCONTROL)
            {
                ProcessPowerController(request.Directive.Header.Name, request.Directive);
            }
            else if (request.Directive.Header.Namespace == NS_POWERLEVELCONTROL)
            {
                ProcessPowerlevelController(request.Directive.Header.Name, request.Directive);
            }
            else if (request.Directive.Header.Namespace == NS_MODECONTROL)
            {
                ProcessModeController(request.Directive);
            }
            else
            {
                string msg = $"Adapter does not support directive namespace {request.Directive.Header.Namespace}";
                log.Warning(msg);
                SendResponseToAlexa(CreateError(request.Directive.Endpoint.EndpointId, AlexaErrorType.INVALID_DIRECTIVE, msg));
            }
        }