#
# $Id$
#
# this example shows usage of ser as user agent
# server which does some functionality (in this
# example, 'log' is used to print a notification
# on a new transaction) and behaves statefuly
# (e.g., it retransmits replies on request
# retransmissions)

# ----------- global configuration parameters ------------------------

debug=3
fork=no
#children=2
log_stderror=yes	# (cmd line: -E)
check_via=yes     # (cmd. line: -v)
dns=0           # (cmd. line: -r)
rev_dns=0      # (cmd. line: -R)
port=5068
reply_to_via=no


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

loadmodule "/usr/lib/ser/modules/sl.so"
loadmodule "/usr/lib/ser/modules/print.so"
loadmodule "/usr/lib/ser/modules/tm.so"
loadmodule "/usr/lib/ser/modules/usrloc.so"

# ----------------- setting module-specific parameters ---------------

# -- usrloc params --

modparam("usrloc", "use_database",   0)
modparam("usrloc", "flush_interval", 3600)

# -------------------------  request routing logic -------------------

# main routing logic

route{
	# for testing purposes, simply okay all REGISTERs
	if (method=="REGISTER") {
		log("REGISTER");
		sl_send_reply("200", "ok");
		#t_replicate("localhost", "9");
		break;
	};
	# print a message if a call was missed

	if ( t_newtran())
    {
		if (method=="ACK") {
			log("oops--ACK to a non-existent transaction");
			drop;
		};
		log("New Transaction Arrived\n");
        # do what you want to do as a sever
		if (uri=~"a@") {
			if (!t_reply("409", "Bizzar Error")) {
				sl_reply_error();
			};
		} else if (uri=~"b@") {
			if (!t_reply("979", "You did not expect this did you")) {
				sl_reply_error();
			};
		} else {
			if (!t_reply("699", "I don't want to chat with you")) {
				sl_reply_error();
			};
		} ;
    } else {
		sl_reply_error();
	};
}