#
# simple quick-start config script - Stand-alone presence server
#
 
# ----------- global configuration parameters ------------------------
 
debug=3      # debug level (cmd line: -dddddddddd)
fork=yes
log_stderror=no    # (cmd line: -E)
children=4

listen=127.0.0.1 
port=5059

dns=no
rev_dns=no

# ------------------ module loading ----------------------------------

loadmodule "db_mysql/db_mysql.so"
loadmodule "maxfwd/maxfwd.so"
loadmodule "textops/textops.so"
loadmodule "tm/tm.so"
loadmodule "sl/sl.so"
loadmodule "rr/rr.so"
loadmodule "presence/presence.so"
loadmodule "presence_xml/presence_xml.so"
loadmodule "avpops/avpops.so"
loadmodule "jsonrpcs/jsonrpcs.so"
 
# ----------------- setting module-specific parameters ---------------
 
# -- rr params --
# add value to ;lr param to make some broken UAs happy
modparam("rr", "enable_full_lr", 1)
 
# -- presence params --
modparam("presence|presence_xml", "db_url", "mysql://kamailio:kamailiorw@localhost/kamailio")
 
modparam("presence_xml", "force_active", 1)
 
modparam("presence", "server_address", "sip:10.10.10.10:5060")

#odparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo_presence")
modparam("jsonrpcs", "transport", 2)
modparam("jsonrpcs", "fifo_name", "kamailio_rpc.fifo")
 
# -------------------------  request routing logic -------------------
 
# main routing logic
 
request_route{
    # initial sanity checks -- messages with
    # max_forwards==0, or excessively long requests
    if (!mf_process_maxfwd_header("10")) {
        sl_send_reply("483","Too Many Hops");
        exit;
    }
 
    if (!is_method("SUBSCRIBE|PUBLISH")) {
        sl_send_reply("488", "Not Acceptable Here");
        exit;
    }
 
    # presence handling
    if (! t_newtran()) {
        sl_reply_error();
        exit;
	}
 
    if(is_method("PUBLISH")) {
        handle_publish();
        t_release();
    } else if( is_method("SUBSCRIBE")) {
        handle_subscribe();
        t_release();
    }
 
    exit;
}