Handle the 'discard' cast.

This commit is contained in:
Feng Lee 2019-08-23 14:31:33 +08:00
parent 9f7cc80c1a
commit 738145677a
2 changed files with 6 additions and 4 deletions

View File

@ -310,6 +310,9 @@ handle({call, From}, Req, State = #state{chan_state = ChanState}) ->
stop(Reason, State#state{chan_state = NChanState})
end;
handle(cast, discard, State) ->
shutdown(discarded, State);
%% Handle cast
handle(cast, Msg, State = #state{chan_state = ChanState}) ->
case emqx_channel:handle_cast(Msg, ChanState) of

View File

@ -244,6 +244,9 @@ websocket_info({call, From, Req}, State = #state{chan_state = ChanState}) ->
stop(Reason, State#state{chan_state = NChanState})
end;
websocket_info({cast, discard}, State) ->
stop(discarded, State);
websocket_info({cast, Msg}, State = #state{chan_state = ChanState}) ->
case emqx_channel:handle_cast(Msg, ChanState) of
{ok, NChanState} ->
@ -295,10 +298,6 @@ websocket_info({timeout, TRef, emit_stats}, State) when is_reference(TRef) ->
websocket_info({timeout, TRef, Msg}, State) when is_reference(TRef) ->
handle_timeout(TRef, Msg, State);
websocket_info({shutdown, discard, {ClientId, ByPid}}, State) ->
?LOG(warning, "Discarded by ~s:~p", [ClientId, ByPid]),
stop(discard, State);
websocket_info({shutdown, conflict, {ClientId, NewPid}}, State) ->
?LOG(warning, "Clientid '~s' conflict with ~p", [ClientId, NewPid]),
stop(conflict, State);