protect from empty clientid

This commit is contained in:
Feng Lee 2015-05-26 15:39:02 +08:00
parent e517cc763d
commit aa3f882edf
1 changed files with 4 additions and 0 deletions

View File

@ -73,6 +73,10 @@ handle_event({connected, ClientId, Params}, State = #state{systop = SysTop}) ->
emqttd_pubsub:publish(event, Msg),
{ok, State};
%%TODO: Protect from undefined clientId...
handle_event({disconnected, undefined, Reason}, State = #state{systop = SysTop}) ->
{ok, State};
handle_event({disconnected, ClientId, Reason}, State = #state{systop = SysTop}) ->
Topic = <<SysTop/binary, "clients/", ClientId/binary, "/disconnected">>,
Msg = #mqtt_message{topic = Topic, payload = payload(disconnected, Reason)},