Merge pull request #272 from emqtt/dev-feng

0.10.3
This commit is contained in:
Feng Lee 2015-08-29 12:00:17 +08:00
commit 0758c5b738
2 changed files with 9 additions and 7 deletions

View File

@ -73,8 +73,7 @@ if [ -z "$NAME_ARG" ]; then
echo "vm.args needs to have either -name or -sname parameter."
exit 1
fi
NAME_ARR=(${NAME_ARG// / })
NODE_NAME=${NAME_ARR[1]}
NODE_NAME=${NAME_ARG##* }
# Extract the target cookie
COOKIE_ARG=`grep '^\-setcookie' $RUNNER_ETC_DIR/vm.args`

View File

@ -34,7 +34,7 @@
-include("emqttd_protocol.hrl").
%% API Exports
-export([start_link/1, ws_loop/3]).
-export([start_link/1, ws_loop/3, subscribe/2]).
-behaviour(gen_server).
@ -61,6 +61,9 @@ start_link(Req) ->
packet_opts = PktOpts,
parser = emqttd_parser:new(PktOpts)}).
subscribe(CPid, TopicTable) ->
gen_server:cast(CPid, {subscribe, TopicTable}).
%%------------------------------------------------------------------------------
%% @private
%% @doc Start WebSocket client.
@ -112,6 +115,10 @@ init([WsPid, Req, ReplyChannel, PktOpts]) ->
handle_call(_Req, _From, State) ->
{reply, error, State}.
handle_cast({subscribe, TopicTable}, State = #client_state{proto_state = ProtoState}) ->
{ok, ProtoState1} = emqttd_protocol:handle({subscribe, TopicTable}, ProtoState),
{noreply, State#client_state{proto_state = ProtoState1}, hibernate};
handle_cast({received, Packet}, State = #client_state{proto_state = ProtoState}) ->
case emqttd_protocol:received(Packet, ProtoState) of
{ok, ProtoState1} ->
@ -136,10 +143,6 @@ handle_info({redeliver, {?PUBREL, PacketId}}, State = #client_state{proto_state
{ok, ProtoState1} = emqttd_protocol:redeliver({?PUBREL, PacketId}, ProtoState),
{noreply, State#client_state{proto_state = ProtoState1}};
handle_info({subscribe, TopicTable}, State = #client_state{proto_state = ProtoState}) ->
{ok, ProtoState1} = emqttd_protocol:handle({subscribe, TopicTable}, ProtoState),
{noreply, State#client_state{proto_state = ProtoState1}};
handle_info({stop, duplicate_id, _NewPid}, State = #client_state{proto_state = ProtoState}) ->
lager:error("Shutdown for duplicate clientid: ~s", [emqttd_protocol:clientid(ProtoState)]),
stop({shutdown, duplicate_id}, State);