From 01cf8b85623c8b88d4369daacc62c5c07055e84e Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Tue, 16 Aug 2016 15:49:00 +0800 Subject: [PATCH] Username --- src/emqttd_protocol.erl | 4 ++-- src/emqttd_session.erl | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/emqttd_protocol.erl b/src/emqttd_protocol.erl index 96ce19dea..bfaee267f 100644 --- a/src/emqttd_protocol.erl +++ b/src/emqttd_protocol.erl @@ -247,9 +247,9 @@ with_puback(Type, Packet = ?PUBLISH_PACKET(_Qos, PacketId), end. -spec(send(mqtt_message() | mqtt_packet(), proto_state()) -> {ok, proto_state()}). -send(Msg, State = #proto_state{client_id = ClientId}) +send(Msg, State = #proto_state{client_id = ClientId, username = Username}) when is_record(Msg, mqtt_message) -> - emqttd:run_hooks('message.delivered', [ClientId], Msg), + emqttd:run_hooks('message.delivered', [{ClientId, Username}], Msg), send(emqttd_message:to_packet(Msg), State); send(Packet, State = #proto_state{sendfun = SendFun}) diff --git a/src/emqttd_session.erl b/src/emqttd_session.erl index facfaf2aa..0e2df6b2e 100644 --- a/src/emqttd_session.erl +++ b/src/emqttd_session.erl @@ -658,11 +658,12 @@ await(#mqtt_message{pktid = PktId}, Session = #session{awaiting_ack = Awaiting Session#session{awaiting_ack = Awaiting1}. acked(PktId, Session = #session{client_id = ClientId, + username = Username, inflight_queue = InflightQ, awaiting_ack = Awaiting}) -> case lists:keyfind(PktId, 1, InflightQ) of {_, Msg} -> - emqttd:run_hooks('message.acked', [ClientId], Msg); + emqttd:run_hooks('message.acked', [{ClientId, Username}], Msg); false -> ?LOG(error, "Cannot find acked pktid: ~p", [PktId], Session) end,