Merge branch 'master' into emq10

This commit is contained in:
Feng Lee 2016-06-30 14:48:07 +08:00
commit c926964b8c
2 changed files with 16 additions and 3 deletions

View File

@ -111,7 +111,7 @@ This is the main emqttd broker configuration file.
File Syntax
-----------
The file users the standard Erlang config syntax, consists of a list of erlang applications and their environments.
The file use the standard Erlang config syntax and consists of a list of erlang applications and their environments.
.. code-block:: erlang
@ -541,7 +541,7 @@ Plugins Folder
TCP Listeners
-------------
Congfigure the TCP listeners for MQTT, MQTT(SSL) and HTTP Protocols.
Configure the TCP listeners for MQTT, MQTT(SSL) and HTTP Protocols.
The most important parameter is 'max_clients' - max concurrent clients allowed.

View File

@ -26,7 +26,8 @@
-include("emqttd_internal.hrl").
%% API Function Exports
-export([start_link/2, session/1, info/1, kick/1]).
-export([start_link/2, session/1, info/1, kick/1,
set_rate_limit/2, get_rate_limit/1]).
%% SUB/UNSUB Asynchronously. Called by plugins.
-export([subscribe/2, unsubscribe/2]).
@ -59,6 +60,12 @@ info(CPid) ->
kick(CPid) ->
gen_server:call(CPid, kick).
set_rate_limit(Cpid, Rl) ->
gen_server:call(Cpid, {set_rate_limit, Rl}).
get_rate_limit(Cpid) ->
gen_server:call(Cpid, get_rate_limit).
subscribe(CPid, TopicTable) ->
gen_server:cast(CPid, {subscribe, TopicTable}).
@ -120,6 +127,12 @@ handle_call(info, _From, State = #client_state{connection = Connection,
handle_call(kick, _From, State) ->
{stop, {shutdown, kick}, ok, State};
handle_call({set_rate_limit, Rl}, _From, State) ->
{reply, ok, State#client_state{rate_limit = Rl}};
handle_call(get_rate_limit, _From, State = #client_state{rate_limit = Rl}) ->
{reply, Rl, State};
handle_call(Req, _From, State) ->
?UNEXPECTED_REQ(Req, State).