-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
I'm having trouble running the server. I'm running mix test with the following test in it:
defmodule MyMqttServerTest do
use ExUnit.Case
alias MQTT.Client
test "greets the world" do
{:ok, connection, false} = MQTT.Client.connect(%{
transport: {:tcp, %{host: "localhost", port: 1883}},
client_id: UUID.uuid1()
})
topic = "/hello"
message = "hello"
{:ok, [{^topic, 0}]} = Client.subscribe(connection, [{topic, 0}])
:ok = Client.publish(connection, topic, message)
assert_receive {:mqtt_client, ^connection, {:publish, ^topic, ^message, _}}
:ok = Client.disconnect(connection)
end
endChild process:
%{
id: MyMqttServer,
type: :worker,
start: {MyMqttServer, :start_link, [[:hello]]}
}defmodule MyMqttServer do
use MQTT.Server
def start_link(state) do
GenServer.start_link(__MODULE__, state, name: __MODULE__)
end
def init(stack) do
{:ok, stack}
end
def init(stack, _) do
{:ok, stack}
end
def handle_subscribe(_topic, _qos, state) do
IO.inspect("I never get output")
{:ok, state}
end
endIt seems to be running but I can't seem to override the fun? I'm still relatively new to this so apologies if this is a simple question.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels