Add send_spam_to_everyone(), add 1% chance of using it
This commit is contained in:
parent
6c543dfc18
commit
a036f119a6
2 changed files with 19 additions and 2 deletions
|
@ -1062,6 +1062,11 @@ do_react_to_env(S) ->
|
||||||
true ->
|
true ->
|
||||||
S
|
S
|
||||||
end,
|
end,
|
||||||
|
%% Perhaps tell the fitness server to spam everyone.
|
||||||
|
case random:uniform(100) of
|
||||||
|
42 -> machi_fitness:send_spam_to_everyone(S#ch_mgr.fitness_svr);
|
||||||
|
_ -> ok
|
||||||
|
end,
|
||||||
%% NOTE: If we use the fitness server's unfit list at the start, then
|
%% NOTE: If we use the fitness server's unfit list at the start, then
|
||||||
%% we would need to add some kind of poll/check for down members to
|
%% we would need to add some kind of poll/check for down members to
|
||||||
%% check if they are now up. Instead, our lazy attempt to read from
|
%% check if they are now up. Instead, our lazy attempt to read from
|
||||||
|
|
|
@ -37,7 +37,8 @@
|
||||||
-export([start_link/1,
|
-export([start_link/1,
|
||||||
get_unfit_list/1, update_local_down_list/3,
|
get_unfit_list/1, update_local_down_list/3,
|
||||||
add_admin_down/3, delete_admin_down/2,
|
add_admin_down/3, delete_admin_down/2,
|
||||||
send_fitness_update_spam/3]).
|
send_fitness_update_spam/3,
|
||||||
|
send_spam_to_everyone/1]).
|
||||||
|
|
||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||||
|
@ -75,6 +76,9 @@ delete_admin_down(PidSpec, DownFLU) ->
|
||||||
send_fitness_update_spam(Pid, FromName, Dict) ->
|
send_fitness_update_spam(Pid, FromName, Dict) ->
|
||||||
gen_server:call(Pid, {incoming_spam, FromName, Dict}, infinity).
|
gen_server:call(Pid, {incoming_spam, FromName, Dict}, infinity).
|
||||||
|
|
||||||
|
send_spam_to_everyone(Pid) ->
|
||||||
|
gen_server:call(Pid, {send_spam_to_everyone}, infinity).
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
init([{MyFluName}|Args]) ->
|
init([{MyFluName}|Args]) ->
|
||||||
|
@ -117,6 +121,9 @@ handle_call({delete_admin_down, DownFLU}, _From,
|
||||||
handle_call({incoming_spam, Author, Dict}, _From, S) ->
|
handle_call({incoming_spam, Author, Dict}, _From, S) ->
|
||||||
{Res, S2} = do_incoming_spam(Author, Dict, S),
|
{Res, S2} = do_incoming_spam(Author, Dict, S),
|
||||||
{reply, Res, S2};
|
{reply, Res, S2};
|
||||||
|
handle_call({send_spam_to_everyone}, _From, S) ->
|
||||||
|
{Res, S2} = do_send_spam_to_everyone(S),
|
||||||
|
{reply, Res, S2};
|
||||||
handle_call(_Request, _From, S) ->
|
handle_call(_Request, _From, S) ->
|
||||||
Reply = whhhhhhhhhhhhhhaaaaaaaaaaaaaaa,
|
Reply = whhhhhhhhhhhhhhaaaaaaaaaaaaaaa,
|
||||||
{reply, Reply, S}.
|
{reply, Reply, S}.
|
||||||
|
@ -299,7 +306,7 @@ calc_unfit2([H|T], G) ->
|
||||||
[H|calc_unfit2(T, G)]
|
[H|calc_unfit2(T, G)]
|
||||||
end.
|
end.
|
||||||
|
|
||||||
do_incoming_spam(Author, Map,
|
do_incoming_spam(_Author, Map,
|
||||||
#state{my_flu_name=MyFluName,pending_map=OldMap,
|
#state{my_flu_name=MyFluName,pending_map=OldMap,
|
||||||
members_dict=MembersDict}=S) ->
|
members_dict=MembersDict}=S) ->
|
||||||
OldMapV = map_value(OldMap),
|
OldMapV = map_value(OldMap),
|
||||||
|
@ -320,6 +327,11 @@ do_incoming_spam(Author, Map,
|
||||||
{ok, S2}
|
{ok, S2}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
do_send_spam_to_everyone(#state{my_flu_name=MyFluName,
|
||||||
|
pending_map=Map,members_dict=MembersDict}=S) ->
|
||||||
|
_ = send_spam(Map, [MyFluName], MembersDict, S),
|
||||||
|
{ok, S}.
|
||||||
|
|
||||||
do_map_change(NewMap, DontSendList, MembersDict,
|
do_map_change(NewMap, DontSendList, MembersDict,
|
||||||
#state{my_flu_name=_MyFluName, pending_map=OldMap}=S) ->
|
#state{my_flu_name=_MyFluName, pending_map=OldMap}=S) ->
|
||||||
send_spam(NewMap, DontSendList, MembersDict, S),
|
send_spam(NewMap, DontSendList, MembersDict, S),
|
||||||
|
|
Loading…
Reference in a new issue