fix format
This commit is contained in:
parent
fb6e3dc066
commit
e8133366e1
|
@ -74,8 +74,9 @@ init(SockArgs = {Transport, Sock, _SockFun}) ->
|
|||
proto_state = emqtt_protocol:init(Transport, NewSock, Peername)}),
|
||||
gen_server:enter_loop(?MODULE, [], State, 10000).
|
||||
|
||||
handle_call(info, _From, State = #state{
|
||||
conn_name=ConnName, proto_state = ProtoState}) ->
|
||||
%%TODO: Not enough...
|
||||
handle_call(info, _From, State = #state{conn_name=ConnName,
|
||||
proto_state = ProtoState}) ->
|
||||
{reply, [{conn_name, ConnName} | emqtt_protocol:info(ProtoState)], State};
|
||||
|
||||
handle_call(Req, _From, State) ->
|
||||
|
@ -87,7 +88,8 @@ handle_cast(Msg, State) ->
|
|||
handle_info(timeout, State) ->
|
||||
stop({shutdown, timeout}, State);
|
||||
|
||||
handle_info({stop, duplicate_id, _NewPid}, State=#state{ proto_state = ProtoState, conn_name=ConnName}) ->
|
||||
handle_info({stop, duplicate_id, _NewPid}, State=#state{proto_state = ProtoState,
|
||||
conn_name=ConnName}) ->
|
||||
%% TODO: to...
|
||||
%% need transfer data???
|
||||
%% emqtt_client:transfer(NewPid, Data),
|
||||
|
@ -145,7 +147,8 @@ terminate(Reason, #state{ peer_name = PeerName, keepalive = KeepAlive, proto_sta
|
|||
{undefined, _} -> ok;
|
||||
{_, {shutdown, Error}} ->
|
||||
emqtt_protocol:shutdown(Error, ProtoState);
|
||||
{_, _} -> ok %TODO:
|
||||
{_, _} ->
|
||||
ok
|
||||
end,
|
||||
ok.
|
||||
|
||||
|
@ -158,8 +161,7 @@ code_change(_OldVsn, State, _Extra) ->
|
|||
process_received_bytes(<<>>, State) ->
|
||||
{noreply, State, hibernate};
|
||||
|
||||
process_received_bytes(Bytes,
|
||||
State = #state{ parse_state = ParseState,
|
||||
process_received_bytes(Bytes, State = #state{parse_state = ParseState,
|
||||
proto_state = ProtoState,
|
||||
conn_name = ConnStr}) ->
|
||||
case emqtt_parser:parse(Bytes, ParseState) of
|
||||
|
@ -170,9 +172,7 @@ process_received_bytes(Bytes,
|
|||
{ok, Packet, Rest} ->
|
||||
case emqtt_protocol:handle_packet(Packet, ProtoState) of
|
||||
{ok, ProtoState1} ->
|
||||
process_received_bytes(
|
||||
Rest,
|
||||
State#state{ parse_state = emqtt_parser:init(),
|
||||
process_received_bytes(Rest, State#state{parse_state = emqtt_parser:init(),
|
||||
proto_state = ProtoState1});
|
||||
{error, Error} ->
|
||||
lager:error("MQTT protocol error ~p for connection ~p~n", [Error, ConnStr]),
|
||||
|
@ -204,8 +204,7 @@ control_throttle(State = #state{ conn_state = Flow,
|
|||
conserve = Conserve}) ->
|
||||
case {Flow, Conserve} of
|
||||
{running, true} -> State #state{conn_state = blocked};
|
||||
{blocked, false} -> run_socket(State #state{
|
||||
conn_state = running });
|
||||
{blocked, false} -> run_socket(State #state{conn_state = running});
|
||||
{_, _} -> run_socket(State)
|
||||
end.
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
%% SOFTWARE.
|
||||
%%------------------------------------------------------------------------------
|
||||
|
||||
-module(emqtt_protocol).
|
||||
|
||||
-include("emqtt.hrl").
|
||||
|
@ -29,14 +28,12 @@
|
|||
%% ------------------------------------------------------------------
|
||||
%% API Function Exports
|
||||
%% ------------------------------------------------------------------
|
||||
|
||||
-export([init/3, client_id/1]).
|
||||
|
||||
-export([handle_packet/2, send_message/2, send_packet/2, redeliver/2, shutdown/2]).
|
||||
|
||||
-export([info/1]).
|
||||
|
||||
|
||||
%% ------------------------------------------------------------------
|
||||
%% Protocol State
|
||||
%% ------------------------------------------------------------------
|
||||
|
@ -54,20 +51,12 @@
|
|||
will_msg
|
||||
}).
|
||||
|
||||
%%----------------------------------------------------------------------------
|
||||
|
||||
-ifdef(use_specs).
|
||||
|
||||
-type(proto_state() :: #proto_state{}).
|
||||
|
||||
-spec(send_message({pid() | tuple(), mqtt_message()}, proto_state()) -> {ok, proto_state()}).
|
||||
|
||||
-spec(handle_packet(mqtt_packet(), proto_state()) -> {ok, proto_state()} | {error, any()}).
|
||||
|
||||
-endif.
|
||||
|
||||
%%----------------------------------------------------------------------------
|
||||
|
||||
-define(PACKET_TYPE(Packet, Type),
|
||||
Packet = #mqtt_packet{header = #mqtt_packet_header { type = Type }}).
|
||||
|
||||
|
|
Loading…
Reference in New Issue