mqtt_message, mqtt_delivery

This commit is contained in:
Feng Lee 2016-08-15 17:30:27 +08:00
parent f166143cd0
commit 123f9b444c
1 changed files with 17 additions and 38 deletions

View File

@ -14,8 +14,6 @@
%% limitations under the License. %% limitations under the License.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% MQTT Broker Header
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Banner %% Banner
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
@ -77,30 +75,10 @@
-type(mqtt_subscription() :: #mqtt_subscription{}). -type(mqtt_subscription() :: #mqtt_subscription{}).
%% {<<"a/b/c">>, '$queue', <<"client1">>}
%% {<<"a/b/c">>, undefined, <0.31.0>}
%% {<<"a/b/c">>, <<"group1">>, <<"client2">>}
%% -record(mqtt_subscription, {topic, share, destination :: pid() | binary()}).
%%--------------------------------------------------------------------
%% MQTT Credential
%%--------------------------------------------------------------------
-record(mqtt_credential, {
clientid :: binary() | undefined, %% ClientId
username :: binary() | undefined, %% Username
token :: binary() | undefined,
cookie :: binary() | undefined
}).
-type(mqtt_credential() :: #mqtt_credential{}).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% MQTT Client %% MQTT Client
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-type ws_header_key() :: atom() | binary() | string().
-type ws_header_val() :: atom() | binary() | string() | integer().
-record(mqtt_client, { -record(mqtt_client, {
client_id :: binary() | undefined, client_id :: binary() | undefined,
client_pid :: pid(), client_pid :: pid(),
@ -110,7 +88,9 @@
proto_ver :: 3 | 4, proto_ver :: 3 | 4,
keepalive = 0, keepalive = 0,
will_topic :: undefined | binary(), will_topic :: undefined | binary(),
ws_initial_headers :: list({ws_header_key(), ws_header_val()}), token :: binary() | undefined, %% auth token
cookie :: binary() | undefined, %% auth cookie
%%ws_initial_headers :: list({ws_header_key(), ws_header_val()}),
connected_at :: erlang:timestamp() connected_at :: erlang:timestamp()
}). }).
@ -138,17 +118,14 @@
msgid :: mqtt_msgid(), %% Global unique message ID msgid :: mqtt_msgid(), %% Global unique message ID
pktid :: mqtt_pktid(), %% PacketId pktid :: mqtt_pktid(), %% PacketId
topic :: binary(), %% Topic that the message is published to topic :: binary(), %% Topic that the message is published to
sender :: pid(), %% Pid of the sender/publisher
from,
credential :: mqtt_credential(), %% Credential of the sender/publisher
qos = 0 :: 0 | 1 | 2, %% Message QoS qos = 0 :: 0 | 1 | 2, %% Message QoS
flags = [] :: [retain | dup | sys], %% Message Flags flags = [] :: [retain | dup | sys], %% Message Flags
retain = false :: boolean(), %% Retain flag retain = false :: boolean(), %% Retain flag
dup = false :: boolean(), %% Dup flag dup = false :: boolean(), %% Dup flag
sys = false :: boolean(), %% $SYS flag sys = false :: boolean(), %% $SYS flag
headers = [] :: list(),
payload :: binary(), %% Payload payload :: binary(), %% Payload
timestamp :: erlang:timestamp(), %% os:timestamp timestamp :: erlang:timestamp() %% os:timestamp
extra = [] :: list()
}). }).
-type(mqtt_message() :: #mqtt_message{}). -type(mqtt_message() :: #mqtt_message{}).
@ -157,6 +134,8 @@
%% MQTT Delivery %% MQTT Delivery
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-record(mqtt_delivery, { -record(mqtt_delivery, {
sender :: pid(), %% Pid of the sender/publisher
from :: binary(),
message :: mqtt_message(), %% Message message :: mqtt_message(), %% Message
flows :: list() flows :: list()
}). }).