mqtt 3.1.1 protocol
This commit is contained in:
parent
034b1a789f
commit
c9d3e2d291
|
@ -1,6 +1,11 @@
|
||||||
eMQTT ChangeLog
|
eMQTT ChangeLog
|
||||||
==================
|
==================
|
||||||
|
|
||||||
|
TODO: 0.2.1 (2014-12-31)
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Pass MQTT 3.1.1 Tests
|
||||||
|
|
||||||
0.2.0 (2014-12-07)
|
0.2.0 (2014-12-07)
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
%% ---------------------------------
|
%% ---------------------------------
|
||||||
%% banner
|
%% banner
|
||||||
%% ---------------------------------
|
%% ---------------------------------
|
||||||
-define(COPYRIGHT, "Copyright (C) 2014, Feng Lee<feng@slimchat.io>").
|
-define(COPYRIGHT, "Copyright (C) 2014, Feng Lee<feng@emqtt.io>").
|
||||||
|
|
||||||
-define(LICENSE_MESSAGE, "Licensed under MIT").
|
-define(LICENSE_MESSAGE, "Licensed under MIT").
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
-module(emqtt_app).
|
-module(emqtt_app).
|
||||||
|
|
||||||
-author('feng@slimchat.io').
|
-author('feng@emqtt.io').
|
||||||
|
|
||||||
-behaviour(application).
|
-behaviour(application).
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
-module(emqtt_auth).
|
-module(emqtt_auth).
|
||||||
|
|
||||||
-author('feng@slimchat.io').
|
-author('feng@emqtt.io').
|
||||||
|
|
||||||
-include("emqtt.hrl").
|
-include("emqtt.hrl").
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
-module(emqtt_auth_anonymous).
|
-module(emqtt_auth_anonymous).
|
||||||
|
|
||||||
-author('feng@slimchat.io').
|
-author('feng@emqtt.io').
|
||||||
|
|
||||||
-export([init/1,
|
-export([init/1,
|
||||||
add/2,
|
add/2,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
-module(emqtt_auth_internal).
|
-module(emqtt_auth_internal).
|
||||||
|
|
||||||
-author('feng@slimchat.io').
|
-author('feng@emqtt.io').
|
||||||
|
|
||||||
-include("emqtt.hrl").
|
-include("emqtt.hrl").
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
-module(emqtt_client).
|
-module(emqtt_client).
|
||||||
|
|
||||||
-author('feng@slimchat.io').
|
-author('feng@emqtt.io').
|
||||||
|
|
||||||
-behaviour(gen_server).
|
-behaviour(gen_server).
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
%client manager
|
%client manager
|
||||||
-module(emqtt_cm).
|
-module(emqtt_cm).
|
||||||
|
|
||||||
-author('feng@slimchat.io').
|
-author('feng@emqtt.io').
|
||||||
|
|
||||||
-behaviour(gen_server).
|
-behaviour(gen_server).
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
-module(emqtt_ctl).
|
-module(emqtt_ctl).
|
||||||
|
|
||||||
-author('feng@slimchat.io').
|
-author('feng@emqtt.io').
|
||||||
|
|
||||||
-include("emqtt.hrl").
|
-include("emqtt.hrl").
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
-module(emqtt_db).
|
-module(emqtt_db).
|
||||||
|
|
||||||
-author('feng@slimchat.io').
|
-author('feng@emqtt.io').
|
||||||
|
|
||||||
-export([init/0, stop/0]).
|
-export([init/0, stop/0]).
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
-module(emqtt_http).
|
-module(emqtt_http).
|
||||||
|
|
||||||
-author('feng@slimchat.io').
|
-author('feng@emqtt.io').
|
||||||
|
|
||||||
-include("emqtt.hrl").
|
-include("emqtt.hrl").
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
-module(emqtt_keep_alive).
|
-module(emqtt_keep_alive).
|
||||||
|
|
||||||
-author('feng@slimchat.io').
|
-author('feng@emqtt.io').
|
||||||
|
|
||||||
-export([new/2,
|
-export([new/2,
|
||||||
state/1,
|
state/1,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
-module(emqtt_monitor).
|
-module(emqtt_monitor).
|
||||||
|
|
||||||
-author('feng@slimchat.io').
|
-author('feng@emqtt.io').
|
||||||
|
|
||||||
-behavior(gen_server).
|
-behavior(gen_server).
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
-module(emqtt_net).
|
-module(emqtt_net).
|
||||||
|
|
||||||
-author('feng@slimchat.io').
|
-author('feng@emqtt.io').
|
||||||
|
|
||||||
-export([tcp_name/3, tcp_host/1, getopts/2, setopts/2, getaddr/2, port_to_listeners/1]).
|
-export([tcp_name/3, tcp_host/1, getopts/2, setopts/2, getaddr/2, port_to_listeners/1]).
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
-record(proto_state, {
|
-record(proto_state, {
|
||||||
socket,
|
socket,
|
||||||
|
connected = false, %received CONNECT action?
|
||||||
message_id,
|
message_id,
|
||||||
client_id,
|
client_id,
|
||||||
clean_sess,
|
clean_sess,
|
||||||
|
@ -43,8 +44,7 @@
|
||||||
|
|
||||||
-export([info/1]).
|
-export([info/1]).
|
||||||
|
|
||||||
-define(FRAME_TYPE(Frame, Type),
|
-define(FRAME_TYPE(Type), #mqtt_frame{ fixed = #mqtt_frame_fixed{ type = Type }}).
|
||||||
Frame = #mqtt_frame{ fixed = #mqtt_frame_fixed{ type = Type }}).
|
|
||||||
|
|
||||||
initial_state(Socket) ->
|
initial_state(Socket) ->
|
||||||
#proto_state{
|
#proto_state{
|
||||||
|
@ -71,6 +71,23 @@ info(#proto_state{ message_id = MsgId,
|
||||||
State :: proto_state(),
|
State :: proto_state(),
|
||||||
NewState :: proto_state().
|
NewState :: proto_state().
|
||||||
|
|
||||||
|
|
||||||
|
%%CONNECT – Client requests a connection to a Server
|
||||||
|
|
||||||
|
%%A Client can only send the CONNECT Packet once over a Network Connection. 369
|
||||||
|
|
||||||
|
%%First CONNECT
|
||||||
|
handle_frame(Frame = ?FRAME_TYPE(?CONNECT), State = #proto_state{connected = false}) ->
|
||||||
|
handle_connect(Frame, State#proto_state{connected = true});
|
||||||
|
|
||||||
|
%%Sencond CONNECT
|
||||||
|
handle_frame(?FRAME_TYPE(?CONNECT), State = #proto_state{connected = true}) ->
|
||||||
|
{error, bad_connect, State};
|
||||||
|
|
||||||
|
%%Received other packets when CONNECT not arrived.
|
||||||
|
handle_frame(_Frame, State = #proto_state{connected = false}) ->
|
||||||
|
{error, no_connected, State};
|
||||||
|
|
||||||
handle_frame(Frame = #mqtt_frame{ fixed = #mqtt_frame_fixed{ type = Type }},
|
handle_frame(Frame = #mqtt_frame{ fixed = #mqtt_frame_fixed{ type = Type }},
|
||||||
State = #proto_state{client_id = ClientId}) ->
|
State = #proto_state{client_id = ClientId}) ->
|
||||||
lager:info("frame from ~s: ~p", [ClientId, Frame]),
|
lager:info("frame from ~s: ~p", [ClientId, Frame]),
|
||||||
|
@ -81,14 +98,13 @@ handle_frame(Frame = #mqtt_frame{ fixed = #mqtt_frame_fixed{ type = Type }},
|
||||||
{error, Reason, State}
|
{error, Reason, State}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
handle_request(?CONNECT,
|
handle_connect(#mqtt_frame{ variable = #mqtt_frame_connect{
|
||||||
#mqtt_frame{ variable = #mqtt_frame_connect{
|
username = Username,
|
||||||
username = Username,
|
password = Password,
|
||||||
password = Password,
|
proto_ver = ProtoVersion,
|
||||||
proto_ver = ProtoVersion,
|
clean_sess = CleanSess,
|
||||||
clean_sess = CleanSess,
|
keep_alive = AlivePeriod,
|
||||||
keep_alive = AlivePeriod,
|
client_id = ClientId } = Var}, State0 = #proto_state{socket = Sock}) ->
|
||||||
client_id = ClientId } = Var}, State0 = #proto_state{socket = Sock}) ->
|
|
||||||
State = State0#proto_state{client_id = ClientId},
|
State = State0#proto_state{client_id = ClientId},
|
||||||
{ReturnCode, State1} =
|
{ReturnCode, State1} =
|
||||||
case {lists:member(ProtoVersion, proplists:get_keys(?PROTOCOL_NAMES)),
|
case {lists:member(ProtoVersion, proplists:get_keys(?PROTOCOL_NAMES)),
|
||||||
|
@ -117,7 +133,7 @@ handle_request(?CONNECT,
|
||||||
fixed = #mqtt_frame_fixed{ type = ?CONNACK },
|
fixed = #mqtt_frame_fixed{ type = ?CONNACK },
|
||||||
variable = #mqtt_frame_connack{
|
variable = #mqtt_frame_connack{
|
||||||
return_code = ReturnCode }}),
|
return_code = ReturnCode }}),
|
||||||
{ok, State1};
|
{ok, State1}.
|
||||||
|
|
||||||
handle_request(?PUBLISH, Frame=#mqtt_frame{
|
handle_request(?PUBLISH, Frame=#mqtt_frame{
|
||||||
fixed = #mqtt_frame_fixed{qos = ?QOS_0}}, State) ->
|
fixed = #mqtt_frame_fixed{qos = ?QOS_0}}, State) ->
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
-module(emqtt_pubsub).
|
-module(emqtt_pubsub).
|
||||||
|
|
||||||
-author('feng@slimchat.io').
|
-author('feng@emqtt.io').
|
||||||
|
|
||||||
-include("emqtt.hrl").
|
-include("emqtt.hrl").
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
-module(emqtt_queue_sup).
|
-module(emqtt_queue_sup).
|
||||||
|
|
||||||
-author('feng@slimchat.io').
|
-author('feng@emqtt.io').
|
||||||
|
|
||||||
-behavior(supervisor).
|
-behavior(supervisor).
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
-module(emqtt_retained).
|
-module(emqtt_retained).
|
||||||
|
|
||||||
-author('feng@slimchat.io').
|
-author('feng@emqtt.io').
|
||||||
|
|
||||||
%%TODO: FIXME Later...
|
%%TODO: FIXME Later...
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -89,3 +89,4 @@ retained(Msg = #mqtt_msg{retain = true, topic = Topic}) ->
|
||||||
emqtt_retained:insert(Topic, Msg), Msg;
|
emqtt_retained:insert(Topic, Msg), Msg;
|
||||||
|
|
||||||
retained(Msg) -> Msg.
|
retained(Msg) -> Msg.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
%%-----------------------------------------------------------------------------
|
||||||
|
%% Copyright (c) 2015, Feng Lee <feng@emqtt.io>
|
||||||
|
%%
|
||||||
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
%% in the Software without restriction, including without limitation the rights
|
||||||
|
%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
%% copies of the Software, and to permit persons to whom the Software is
|
||||||
|
%% furnished to do so, subject to the following conditions:
|
||||||
|
%%
|
||||||
|
%% The above copyright notice and this permission notice shall be included in all
|
||||||
|
%% copies or substantial portions of the Software.
|
||||||
|
%%
|
||||||
|
%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
%% SOFTWARE.
|
||||||
|
%%------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-module(emqtt_session).
|
||||||
|
|
|
@ -1,5 +1,99 @@
|
||||||
|
%%-----------------------------------------------------------------------------
|
||||||
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
|
%%
|
||||||
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
%% in the Software without restriction, including without limitation the rights
|
||||||
|
%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
%% copies of the Software, and to permit persons to whom the Software is
|
||||||
|
%% furnished to do so, subject to the following conditions:
|
||||||
|
%%
|
||||||
|
%% The above copyright notice and this permission notice shall be included in all
|
||||||
|
%% copies or substantial portions of the Software.
|
||||||
|
%%
|
||||||
|
%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
%% SOFTWARE.
|
||||||
|
%%------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
%%------------------------------------------------------------------------------
|
||||||
|
%%
|
||||||
|
%% The Session state in the Server consists of:
|
||||||
|
%% The existence of a Session, even if the rest of the Session state is empty.
|
||||||
|
%% The Client’s subscriptions.
|
||||||
|
%% QoS 1 and QoS 2 messages which have been sent to the Client, but have not been completely
|
||||||
|
%% acknowledged.
|
||||||
|
%% QoS 1 and QoS 2 messages pending transmission to the Client.
|
||||||
|
%% QoS 2 messages which have been received from the Client, but have not been completely
|
||||||
|
%% acknowledged.
|
||||||
|
%% Optionally, QoS 0 messages pending transmission to the Client.
|
||||||
|
%%
|
||||||
|
%%------------------------------------------------------------------------------
|
||||||
|
|
||||||
-module(emqtt_sm).
|
-module(emqtt_sm).
|
||||||
|
|
||||||
%%emqtt session manager...
|
%%emqtt session manager...
|
||||||
|
|
||||||
%%cleanSess: true | false
|
%%cleanSess: true | false
|
||||||
|
|
||||||
|
-include("emqtt.hrl").
|
||||||
|
|
||||||
|
-behaviour(gen_server).
|
||||||
|
|
||||||
|
-define(SERVER, ?MODULE).
|
||||||
|
|
||||||
|
%% ------------------------------------------------------------------
|
||||||
|
%% API Function Exports
|
||||||
|
%% ------------------------------------------------------------------
|
||||||
|
|
||||||
|
-export([start_link/0]).
|
||||||
|
|
||||||
|
-export([create/2, resume/2, destroy/1]).
|
||||||
|
|
||||||
|
%% ------------------------------------------------------------------
|
||||||
|
%% gen_server Function Exports
|
||||||
|
%% ------------------------------------------------------------------
|
||||||
|
|
||||||
|
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||||
|
terminate/2, code_change/3]).
|
||||||
|
|
||||||
|
%% ------------------------------------------------------------------
|
||||||
|
%% API Function Definitions
|
||||||
|
%% ------------------------------------------------------------------
|
||||||
|
|
||||||
|
start_link() ->
|
||||||
|
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
|
||||||
|
|
||||||
|
create(ClientId, Pid) -> ok.
|
||||||
|
|
||||||
|
resume(ClientId, Pid) -> ok.
|
||||||
|
|
||||||
|
destroy(ClientId) -> ok.
|
||||||
|
|
||||||
|
%% ------------------------------------------------------------------
|
||||||
|
%% gen_server Function Definitions
|
||||||
|
%% ------------------------------------------------------------------
|
||||||
|
|
||||||
|
init(Args) ->
|
||||||
|
{ok, Args}.
|
||||||
|
|
||||||
|
handle_call(_Request, _From, State) ->
|
||||||
|
{reply, ok, State}.
|
||||||
|
|
||||||
|
handle_cast(_Msg, State) ->
|
||||||
|
{noreply, State}.
|
||||||
|
|
||||||
|
handle_info(_Info, State) ->
|
||||||
|
{noreply, State}.
|
||||||
|
|
||||||
|
terminate(_Reason, _State) ->
|
||||||
|
ok.
|
||||||
|
|
||||||
|
code_change(_OldVsn, State, _Extra) ->
|
||||||
|
{ok, State}.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
-module(emqtt_sup).
|
-module(emqtt_sup).
|
||||||
|
|
||||||
-author('feng@slimchat.io').
|
-author('feng@emqtt.io').
|
||||||
|
|
||||||
-include("emqtt.hrl").
|
-include("emqtt.hrl").
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2014, Feng Lee <feng@slimchat.io>
|
%% Copyright (c) 2014, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
-module(emqtt_topic).
|
-module(emqtt_topic).
|
||||||
|
|
||||||
-author('feng@slimchat.io').
|
-author('feng@emqtt.io').
|
||||||
|
|
||||||
-import(lists, [reverse/1]).
|
-import(lists, [reverse/1]).
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
durable queue data...
|
|
@ -30,3 +30,7 @@ Connection, others can span multiple consecutive Network Connections between a C
|
||||||
|
|
||||||
An expression contained in a Subscription, to indicate an interest in one or more topics. A Topic Filter can include wildcard characters.
|
An expression contained in a Subscription, to indicate an interest in one or more topics. A Topic Filter can include wildcard characters.
|
||||||
|
|
||||||
|
|
||||||
|
## Packet Identifier
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue