public SubscriptionActor(IActorRef manager, MqttConfig mqttConfig, string topic, string alexaResponseTopic) { log.Info("Creating..."); this.jsonSettings = new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver() }; this.jsonSerializer = JsonSerializer.CreateDefault(jsonSettings); this.jsonEncoding = Encoding.UTF8; this.manager = manager; this.mqttConfig = mqttConfig; this.topic = topic; this.alexaResponseTopic = alexaResponseTopic; this.processors = new Dictionary <AloxiMessageOperation, List <IActorRef> >(); this.isSubscribed = false; Receive <MediationMessage.Received>(ReceivedReceived); Receive <MediationMessage.Publish>(ReceivedPublish); Receive <MediationMessage.PublishAlexaResponse>(ReceivedPublishAlexaResponse); Receive <MediationMessage.RegisterProcessor>(ReceivedRegisterProcessor); Receive <MediationMessage.StateConnectionClosed>(ReceivedStateConnectionClosed); Receive <MediationMessage.StateSubscribed>(ReceivedStateSubscribed); Receive <MediationMessage.StateUnsubscribed>(ReceivedStateUnsubscribed); Receive <MediationMessage.RequestState>(ReceivedRequestState); Receive <MediationMessage.RequestConnect>(ReceivedConnect); }
public static MqttClient For(MqttConfig mqttConfig) { if (string.IsNullOrWhiteSpace(mqttConfig.CaCertPath)) { return(ConstructClientDirectlyInAws(mqttConfig.Endpoint)); } return(ConstructClientBasedOnCertificate(mqttConfig.Endpoint, mqttConfig.CaCertPath, mqttConfig.ClientCertPath)); }
public static MediationConfig From(IConfigurationSection configurationSection) { var c = configurationSection.Get <Config>(); var mMqtt = new Mqtt.MqttConfig(c.Mqtt.Endpoint, c.Mqtt.CaPath, c.Mqtt.CertPath, c.Mqtt.ClientId); var mSignalR = new SignalR.Config(c.SignalR.ConnectionString); return(new MediationConfig(c.ActiveClients, c.SubscriptionTopic, c.AlexaResponseTopic, mMqtt, mSignalR)); }
private void SetupMqttMediationClient() { try { var mqttConfig = new Mqtt.MqttConfig(mediationConfig.Mqtt.Endpoint, mediationConfig.Mqtt.CaCertPath, mediationConfig.Mqtt.ClientCertPath, mediationConfig.Mqtt.ClientId); this.mqttManager = Context.ActorOf(Props.Create(() => new Mqtt.ManagerActor(mqttConfig, mediationConfig.SubscriptionTopic, mediationConfig.AlexaResponseTopic)), "mqtt"); } catch (Exception ex) { log.Error(ex, "Initializing of MQTT node failed"); } }
public ManagerActor(MqttConfig mqttConfig, string subscriptionTopic, string alexaResponseTopic) { this.subscriptionTopic = subscriptionTopic; this.alexaResponseTopic = alexaResponseTopic; this.mqttConfig = mqttConfig; this.subscriber = ActorRefs.Nobody; this.registeredProcessors = new List <MediationMessage>(); Receive <MediationMessage.Publish>(ForwardToSubscriptionActor); Receive <MediationMessage.PublishAlexaResponse>(ForwardToSubscriptionActor); Receive <MediationMessage.RegisterProcessor>(ReceivedRegisterProcessor); Receive <MediationMessage.RequestState>(ForwardToSubscriptionActor); Receive <MqttMessage.EstablishSubscription>(ReceivedEstablishSubscription); Receive <Terminated>(ReceivedSubscriberTerminated); }
public MediationConfig(MediationClientType[] activeClients, string subscriptionTopic, string alexaResponseTopic, Mqtt.MqttConfig mqtt, SignalR.Config signalR) { this.ActiveClients = activeClients.ToImmutableArray(); this.SubscriptionTopic = subscriptionTopic; this.AlexaResponseTopic = alexaResponseTopic; this.Mqtt = mqtt; this.SignalR = signalR; }