anchor.diff:  connect_amoc_user(Id) ->
       Cfg = make_user_cfg(Id),
       {ok, Client, _} = escalus_connection:start(Cfg),
  -    send_presence_available(Client),
       erlang:put(jid, Client#client.jid),
       Client.
   
  
positive.code: start_user(Client) ->
      lager:debug("User process ~p", [self()]),
      erlang:monitor(process, Client#client.rcv_pid),
      create_muc_light_room(Client),
      escalus_tcp:set_active(Client#client.rcv_pid, true),
      send_info_to_coordinator(Client),
      user_loop(Client, 0).
  
  send_info_to_coordinator(Client) ->
      lager:debug("Process ~p, sending info about myself to coordinator", [self()]),
      coordinator:register_user(Client).
  
  user_loop(Client, Time) ->
      receive
          publish_item ->
              RoomJid = get_room(),
              amoc_metrics:update_counter(message_published, 1),
              Now = os:system_time(microsecond),
              send_message_to_room(Client, RoomJid),
              schedule_publishing(self()),
              update_publication_interval(Time, Now),
              user_loop(Client, Now);
          {stanza, _, #xmlel{name = <<"message">>} = Stanza, #{recv_timestamp := TimeStamp}} ->
              case exml_query:subelement_with_name_and_ns(Stanza, <<"x">>, <<"urn:xmpp:muclight:0#affiliations">>) of
                  undefined ->
                      Sent = get_muc_timestamp(Stanza),
                      amoc_metrics:update_counter(message_received, 1),
                      update_message_ttd(Sent, TimeStamp);
                  _ -> %% affiliation stanza
                      RoomJid = exml_query:attr(Stanza, <<"from">>),
                      add_room(RoomJid)
              end,
              user_loop(Client, Time);
  
          {add_users, MemberJids} ->
              add_users_to_room(Client, MemberJids),
              user_loop(Client, Time);
          remove_user ->
              lager:debug("Removing myself ~p", [self()]),
              remove_self(Client)
      end.
  
  
  schedule_publishing(Pid) ->
      amoc_throttle:send(?PUBLICATION_THROTTLING, Pid, publish_item).
  
  schedule_removal(Pid) ->
      amoc_throttle:send(?REMOVAL_THROTTLING, Pid, remove_user).
  
  update_publication_interval(0, _Now) ->
      ok;
  update_publication_interval(Time, Now) ->
      Interval = Now - Time,
      amoc_metrics:update_time(publication_interval, Interval).
  
  update_message_ttd(Time, Now) ->
      Interval = Now - Time,
      amoc_metrics:update_time(message_ttd, Interval).
  
  remove_self(Client) ->
      UserName = escalus_client:username(Client),
      UserServer = escalus_client:server(Client),
      Path = list_to_binary(["/api/users/", UserServer, "/", UserName]),
      Host = get_parameter(mim_rest_endpoint),
      {ok, R} = http_req:request(Host, Path, <<"DELETE">>, []),
      lager:debug("removing user ~p:~n~p", [UserName,R]),
      ?STOP_USER.
  
  %%------------------------------------------------------------------------------------------------
  %% User connection
  
negative.code:         {ok, Settings} ->
              http_req:start(),
  
              config:store_scenario_settings(Settings),
              config:dump_settings(),
  
              [RoomPublicationRate, NodePublicationRate, RoomCreationRate, NodeCreationRate, GDPRRemovalRate] =
                  [proplists:get_value(Key, Settings) ||
                      Key <- [room_publication_rate, node_publication_rate,
                              room_creation_rate, node_creation_rate,
                              gdpr_removal_rate]],
              amoc_throttle:start(?ROOM_CREATION_THROTTLING, RoomCreationRate),
              amoc_throttle:start(?ROOM_PUBLICATION_THROTTLING, RoomPublicationRate),
              amoc_throttle:start(?NODE_CREATION_THROTTLING, NodeCreationRate),
              amoc_throttle:start(?NODE_PUBLICATION_THROTTLING, NodePublicationRate),
              amoc_throttle:start(?REMOVAL_THROTTLING, GDPRRemovalRate),
  
              start_coordinator(Settings),
  