Added Ecto, Cassandra and Auctions repo
This commit is contained in:
@@ -11,8 +11,6 @@ defmodule NeonVertigoService.Mqtt.Server do
|
||||
|
||||
# Callbacks
|
||||
def handle_continue(:post_init, {}) do
|
||||
:ok = NeonVertigoService.MessageProcessor.init_tables()
|
||||
|
||||
mqtt_config = Application.fetch_env!(:neon_vertigo_service, :mqtt_params)
|
||||
{:ok, mqtt_pid} = Supervisor.start_child(
|
||||
NeonVertigoService.Mqtt.Supervisor,
|
||||
@@ -34,10 +32,14 @@ defmodule NeonVertigoService.Mqtt.Server do
|
||||
IO.inspect(msg)
|
||||
%{payload: payload_str, topic: topic_str, properties: properties} = msg
|
||||
topic = String.split(topic_str, "/")
|
||||
response_topic = properties[:"Response-Topic"]
|
||||
payload = JSON.decode!(payload_str)
|
||||
|
||||
case NeonVertigoService.MessageProcessor.process_message(topic, payload, properties) do
|
||||
{:reply, topic, data} -> :emqtt.publish(mqtt_pid, topic, data)
|
||||
{:reply, data} ->
|
||||
if is_binary(response_topic) && String.length(response_topic) > 0 do
|
||||
:emqtt.publish(mqtt_pid, response_topic, JSON.encode!(data), retain: true)
|
||||
end
|
||||
:noreply -> nil
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user