Add emqx_message:make/4 and fix whitespace
This commit is contained in:
parent
bffdd2ba74
commit
055de617fc
|
@ -1,24 +1,25 @@
|
||||||
%%--------------------------------------------------------------------
|
%%%===================================================================
|
||||||
%% Copyright (c) 2013-2018 EMQ Inc. All rights reserved.
|
%%% Copyright (c) 2013-2018 EMQ Inc. All rights reserved.
|
||||||
%%
|
%%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%%% you may not use this file except in compliance with the License.
|
||||||
%% You may obtain a copy of the License at
|
%%% You may obtain a copy of the License at
|
||||||
%%
|
%%%
|
||||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
%%% http://www.apache.org/licenses/LICENSE-2.0
|
||||||
%%
|
%%%
|
||||||
%% Unless required by applicable law or agreed to in writing, software
|
%%% Unless required by applicable law or agreed to in writing, software
|
||||||
%% distributed under the License is distributed on an "AS IS" BASIS,
|
%%% distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
%% See the License for the specific language governing permissions and
|
%%% See the License for the specific language governing permissions and
|
||||||
%% limitations under the License.
|
%%% limitations under the License.
|
||||||
%%--------------------------------------------------------------------
|
%%%===================================================================
|
||||||
|
|
||||||
-module(emqx_message).
|
-module(emqx_message).
|
||||||
|
|
||||||
-include("emqx.hrl").
|
-include("emqx.hrl").
|
||||||
|
-include("emqx_mqtt.hrl").
|
||||||
|
|
||||||
-export([make/3]).
|
-export([make/3, make/4]).
|
||||||
|
|
||||||
-export([get_flag/2, get_flag/3, set_flag/2, unset_flag/2]).
|
-export([get_flag/2, get_flag/3, set_flag/2, unset_flag/2]).
|
||||||
|
|
||||||
|
@ -29,8 +30,11 @@
|
||||||
%% Create a default message
|
%% Create a default message
|
||||||
-spec(make(atom() | client(), topic(), payload()) -> message()).
|
-spec(make(atom() | client(), topic(), payload()) -> message()).
|
||||||
make(From, Topic, Payload) when is_atom(From); is_record(From, client) ->
|
make(From, Topic, Payload) when is_atom(From); is_record(From, client) ->
|
||||||
|
make(From, ?QOS_0, Topic, Payload).
|
||||||
|
|
||||||
|
make(From, QoS, Topic, Payload) when is_atom(From); is_record(From, client) ->
|
||||||
#message{id = msgid(),
|
#message{id = msgid(),
|
||||||
qos = 0,
|
qos = ?QOS_I(QoS),
|
||||||
from = From,
|
from = From,
|
||||||
sender = self(),
|
sender = self(),
|
||||||
flags = #{},
|
flags = #{},
|
||||||
|
|
Loading…
Reference in New Issue