fix
This commit is contained in:
parent
ce0d447e8f
commit
eea16209ef
@ -13,6 +13,7 @@
|
||||
-behaviour(gen_server).
|
||||
|
||||
%% API
|
||||
-export([test/1]).
|
||||
-export([start_link/2, get_name/1, get_pid/1, publish/4]).
|
||||
|
||||
%% gen_server callbacks
|
||||
@ -26,6 +27,10 @@
|
||||
is_connected = false :: boolean()
|
||||
}).
|
||||
|
||||
test(Id) when is_binary(Id) ->
|
||||
Pid = get_pid(<<"1">>),
|
||||
publish(Pid, <<"/host/", Id/binary>>, <<"hello world">>, 1).
|
||||
|
||||
%%%===================================================================
|
||||
%%% API
|
||||
%%%===================================================================
|
||||
@ -124,6 +129,17 @@ handle_cast(_Request, State = #state{}) ->
|
||||
{noreply, NewState :: #state{}} |
|
||||
{noreply, NewState :: #state{}, timeout() | hibernate} |
|
||||
{stop, Reason :: term(), NewState :: #state{}}).
|
||||
handle_info({disconnect, ReasonCode, Properties}, State = #state{host = #host{host_id = HostId}}) ->
|
||||
lager:debug("[iot_host] host: ~p, Recv a DISONNECT packet - ReasonCode: ~p, Properties: ~p", [HostId, ReasonCode, Properties]),
|
||||
{stop, disconnected, State};
|
||||
handle_info({publish, Message = #{packet_id := PacketId, payload := Payload}}, State = #state{emqx_pid = ConnPid, host = #host{host_id = HostId}}) ->
|
||||
lager:debug("[iot_host] host: ~p, Recv a publish packet: ~p, payload: ~p", [HostId, Message, Payload]),
|
||||
% emqtt:pubrec(ConnPid, PacketId),
|
||||
{noreply, State};
|
||||
handle_info({puback, #{packet_id := PacketId, reason_code := ReasonCode}}, State = #state{host = #host{host_id = HostId}}) ->
|
||||
lager:debug("[iot_host] host: ~p, receive puback packet_id: ~p, reason_code: ~p", [HostId, PacketId, ReasonCode]),
|
||||
{noreply, State};
|
||||
|
||||
handle_info(Info, State = #state{host = #host{host_id = HostId}}) ->
|
||||
lager:debug("host_id: ~p, get info: ~p", [HostId, Info]),
|
||||
{noreply, State}.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user