anchor.diff:  %@doc Handles presence stanzas sent by users
   handle_presence(UserState, {User, Server, Resource} = JID) ->
     {IPAddress, _} = ejabberd:get_user_ip(User, Server, Resource),
  -  ?DEBUG("User ~p (~p) is ~p", [JID, IPAddress, State]),
  +  ?DEBUG("User ~p (~p) is ~p", [JID, IPAddress, UserState]),
   
     % Passes over the processing into a new process
     gen_server:cast(?MODULE, {UserState, JID, IPAddress}),
  
positive.code:   AgentData = erlang:list_to_tuple(list:flatmap(fun erlang:tuple_to_list/1, parse_component_jid(User))),
    NewData = {disconnected_at, bson:timenow(),
               agent_data, AgentData},
    % Updates the active flag and appends new data
    bson:append(bson:update(active, false, Doc), NewData);
  doc_close_connection({failure, _}, _, _, _) ->
    % Silently fails
    failure.
  
  %@doc Sends an message as mod_copilot@localhost and performs base64-encoding of the attributes
  
negative.code:   Opts = proplists:get_value(opts, State),
    Host = case proplists:get_value(mongodb, Opts) of
      undefined -> {localhost, 27017};
      Value -> Value
    end,
    {ok, NewConn} = mongo:connect(Host),
    proplists:delete(conn, State) ++ [{conn, NewConn}].
  