Пример #1
0
func TestPoolClose(t *testing.T) {
	conn := redis.New()
	err := conn.Connect("localhost", 6379)
	if err != nil {
		t.Errorf("pool.Close test failed: could not get connection")
	}

	if len(redisStore.pool.connections) != 0 {
		t.Errorf("pool.Close test failed: connection pool not empty")
	}
	redisStore.pool.Close(conn)

	if len(redisStore.pool.connections) != 1 {
		t.Errorf("pool.Close test failed: connection pool length expected to be 1 got %v", len(redisStore.pool.connections))
	}

	conn = redis.New()
	err = conn.Connect("localhost", 6379)
	if err != nil {
		t.Errorf("pool.Close test failed: could not get connection")
	}

	redisStore.pool.Close(conn)
	if len(redisStore.pool.connections) != 1 { //testing maxIdle; maxIdle = 1
		t.Errorf("pool.Close test failed: connection pool length expected to be 1 got %s", len(redisStore.pool.connections))
	}
}
Пример #2
0
func main() {
	var err error

	publisher = redis.New()

	err = publisher.Connect(host, port)

	if err != nil {
		log.Fatalf("Publisher failed to connect: %s\n", err.Error())
		return
	}

	log.Println("Publisher connected to redis-server.")

	consumer = redis.New()

	err = consumer.ConnectNonBlock(host, port)

	if err != nil {
		log.Fatalf("Consumer failed to connect: %s\n", err.Error())
		return
	}

	log.Println("Consumer connected to redis-server.")

	rec := make(chan []string)

	log.Printf("Consumer is now inside a go-routine.\n")
	go consumer.Subscribe(rec, "channel")

	log.Printf("Publisher will send messages in another go-routine\n")

	go func() {
		publisher.Publish("channel", "Hello world!")
		publisher.Publish("channel", "Do you know how to count?")

		for i := 0; i < 3; i++ {
			publisher.Publish("channel", i)
		}
	}()

	log.Printf("Reading subscription...\n")
	var ls []string

	for j := 0; j < 6; j++ {
		ls = <-rec
		log.Printf("Consumer received: %v\n", strings.Join(ls, ", "))
	}

	log.Printf("Done, quitting.\n")

	consumer.Quit()
	publisher.Quit()

}
Пример #3
0
func spawnConsumer() error {
	var err error
	var consumer *redis.Client

	consumer = redis.New()

	err = consumer.ConnectNonBlock(host, port)

	if err != nil {
		log.Fatalf("Consumer failed to connect: %s\n", err.Error())
		return err
	}

	log.Println("Consumer connected to redis-server.")

	rec := make(chan []string)

	log.Printf("Consumer will read exactly 6 messages before quitting.\n")

	go consumer.Subscribe(rec, "channel")

	var ls []string

	for j := 0; j < 6; j++ {
		ls = <-rec
		log.Printf("Consumer received message[%d]: %v\n", j, strings.Join(ls, ", "))
	}

	log.Printf("Closing consumer...\n")

	consumer.Quit()

	return nil
}
Пример #4
0
func main() {
	var err error

	client = redis.New()

	err = client.Connect(host, port)

	if err != nil {
		log.Fatalf("Connect failed: %s\n", err.Error())
		return
	}

	log.Println("Connected to redis-server.")

	log.Printf("DEL mylist")
	client.Del("mylist")

	for i := 0; i < 10; i++ {
		log.Printf("RPUSH mylist %d\n", i*2)
		client.RPush("mylist", i*2)
	}

	log.Printf("LRANGE mylist 0 5")
	var ls []string
	ls, err = client.LRange("mylist", 0, 5)

	for i := 0; i < len(ls); i++ {
		log.Printf("> mylist[%d] = %s\n", i, ls[i])
	}

	client.Quit()

}
Пример #5
0
func main() {
	var s string
	var err error

	client = redis.New()

	err = client.Connect(host, port)

	if err != nil {
		log.Fatalf("Connect failed: %s\n", err.Error())
		return
	}

	log.Println("Connected to redis-server.")

	log.Printf("Sending PING...\n")
	s, err = client.Ping()

	if err != nil {
		log.Fatalf("Could not ping: %s\n", err.Error())
		return
	}

	log.Printf("Received %s!\n", s)

	client.Quit()

}
Пример #6
0
func main() {
	var err error

	consumer = redis.New()

	err = consumer.ConnectNonBlock(host, port)

	if err != nil {
		log.Fatalf("Consumer failed to connect: %s\n", err.Error())
		return
	}

	log.Println("Consumer connected to redis-server.")

	// Subscribing to a channel.
	log.Println("Client is subscribed to a test channel. Try stopping redis-server...")
	rec := make(chan []string, 10)
	err = consumer.Subscribe(rec, "channel")

	if err != nil {
		fmt.Printf("Unsubscribed with error: %s\n", err.Error())
	}

	consumer.Quit()
}
Пример #7
0
func spawnPublisher() error {
	var err error
	var publisher *redis.Client

	publisher = redis.New()

	err = publisher.Connect(host, port)

	if err != nil {
		log.Fatalf("Publisher failed to connect: %s\n", err.Error())
		return err
	}

	log.Println("Publisher connected to redis-server.")

	log.Println("Publishing some messages...")

	publisher.Publish("channel", "Hello world!")
	publisher.Publish("channel", "Do you know how to count?")

	for i := 0; i < 3; i++ {
		publisher.Publish("channel", i)
	}

	log.Printf("Closing publisher...\n")

	publisher.Quit()

	return nil
}
Пример #8
0
// Attempts to create a new named queue.
func NewQueue(name string) (self *Queue, err error) {
	self = &Queue{}

	self.client = redis.New()

	host := os.Getenv("REDIS_SERVER")
	if host == "" {
		host = "127.0.0.1"
	}

	port, _ := strconv.Atoi(os.Getenv("REDIS_PORT"))
	if port == 0 {
		port = redis.DefaultPort
	}

	err = self.client.ConnectWithTimeout(host, redis.DefaultPort, connectTimeout)
	if err != nil {
		return nil, err
	}

	self.name = name
	self.queueName = fmt.Sprintf("%s-queue", self.name)

	return self, nil
}
Пример #9
0
func (r RedisConnection) client() *redis.Client {
	rc := redis.New()
	err := rc.ConnectNonBlock(r.Host, r.Port)
	if err != nil {
		log.Fatalf("FATAL RedisConnection.client(): %s", err)
	}

	return rc
}
Пример #10
0
func rhost_copy(r *Redis_Server) (*Redis_Server, error) {
	rnew := new(Redis_Server)
	rnew.r = redis.New()
	rnew.host = r.host
	rnew.port = r.port
	rnew.db = r.db
	rnew.pass = r.pass
	return rnew, nil
}
Пример #11
0
func init() {
	rand.Seed(time.Now().UnixNano())
	client = redis.New()
	err := client.Connect("localhost", 6379)
	if err != nil {
		log.Fatalf("Connect failed: %s\n", err.Error())
		return
	}

	log.Println("Connected to redis-server.")
}
Пример #12
0
func main() {
	var client *redis.Client

	client = redis.New()
	client.Connect("localhost", 6379)

	s, _ := client.Ping()
	fmt.Println(s)
	client.Incr("hello")
	s, _ = client.Get("hello")
	fmt.Println(s)
	client.Quit()
}
Пример #13
0
func TestPooltestConn(t *testing.T) {
	conn := redis.New()
	err := conn.Connect("localhost", 6379)
	err = redisStore.pool.testConn(conn)
	if err != nil {
		t.Fatalf("testConn test failed: %s", err.Error())
	}

	conn.Quit()
	err = redisStore.pool.testConn(conn)
	if err == nil {
		t.Fatalf("testConn test failed: expected error got nil")
	}
}
Пример #14
0
func main() {
	var err error

	client = redis.New()

	err = client.Connect(host, port)
	if err != nil {
		log.Printf(err.Error())
	}

	compact := "HELLO"
	max := len(compact)

	client.Multi()
	client.Del("keywordlookup")
	client.Del("keywordlookup2")

	for i := 1; i <= max; i++ {
		s := compact[:i]
		client.ZAdd("keywordlookup", 0, s)
		client.ZAdd("keywordlookup2", 0, s)
	}

	client.ZInterStore("keywordmatch", 2, "keywordlookup", "keywordlookup2")
	client.ZRevRange("keywordmatch", 0, 0)
	res, err := client.Exec()

	if err != nil {
		log.Printf(err.Error())
	}

	for _, el := range res {
		switch v := el.(type) {
		case []interface{}:
			log.Printf("Got []interface{}")
			for i, vv := range v {
				log.Printf("Value at index %d (%v) has kind %s, we convert it to string: %v", i, vv, reflect.TypeOf(vv).Kind(), to.String(vv))
			}
		case interface{}:
			log.Printf("Got value of kind %s (%v), we convert it to string: %s\n", reflect.TypeOf(v).Kind(), v, to.String(v))
		}
	}

	client.Quit()

}
Пример #15
0
func main() {
	var rc = redis.New()
	var err error
	if err = rc.Connect("localhost", 6379); err != nil {
		log.Fatalf("Couldn't connect to redis server.")
	}

	if _, err = rc.HSet("key", "field", "value"); err != nil {
		log.Fatalf("Error setting value: %s", err)
	}

	var value string
	if value, err = rc.HGet("key", "field"); err != nil {
		log.Fatalf("Error getting value: %s", err)
	}

	fmt.Printf("Value = %s\n", value)
}
Пример #16
0
func main() {
	var err error

	client = redis.New()

	err = client.Connect(host, port)
	if err != nil {
		log.Printf(err.Error())
	}

	compact := "HELLO"
	max := len(compact)

	client.Multi()
	client.Del("keywordlookup")
	client.Del("keywordlookup2")

	for i := 1; i <= max; i++ {
		s := compact[:i]
		client.ZAdd("keywordlookup", 0, s)
		client.ZAdd("keywordlookup2", 0, s)
	}

	client.ZInterStore("keywordmatch", 2, "keywordlookup", "keywordlookup2")
	client.ZRevRange("keywordmatch", 0, 0)
	res, err := client.Exec()

	if err != nil {
		log.Printf(err.Error())
	}

	for _, v := range res {
		switch m := v.(type) {
		case []interface{}:
			log.Printf("Got an array of type %s with %d elements (%v).\n", reflect.TypeOf(m).Kind(), len(m), string(m[0].(*resp.Message).Interface().([]byte)))
		case *resp.Message:
			log.Printf("Got value of kind %s (%v), we use the integer part: %d\n", reflect.TypeOf(m).Kind(), m, m.Integer)
		}
	}

	client.Quit()

}
Пример #17
0
func main() {
	client = redis.New()
	defer client.Quit()
	err := client.Connect(host, port)
	if err != nil {
		println(err.Error())
		return
	}
	println("connect to redis server")
	//example ping
	println("sending ping")
	s, err = client.Ping()
	if err != nil {
		println("Ping error")
		return
	}
	println("received " + s)
	//end of example ping

	//example set get
	println("set Xargin")
	client.Set("Xargin", 1)
	s, err = client.Get("Xargin")
	if err != nil {
		println("get Xargin error")
		return
	}
	println("get Xargin = " + s)
	//end of exmplae set get

	//example incr
	println("increment Xargin")
	client.Incr("Xargin")
	s, err = client.Get("Xargin")
	if err != nil {
		println("get Xargin err")
		return
	}
	println("get Xargin = " + s)
	//end
	log.Println("end")
}
Пример #18
0
func GetRedisClient() *redis.Client {

	if RedisClientPool == nil {
		RedisClientPool = make(chan *redis.Client, MAX_POOL_SIZE)
	}
	if len(RedisClientPool) == 0 {
		go func() {
			for i := 0; i < MAX_POOL_SIZE; i++ {
				client := redis.New()
				err := client.Connect("localhost", 6379)
				if err != nil {
					panic(err)
				}
				PutRedisClient(client)
			}

		}()
	}
	return <-RedisClientPool
}
Пример #19
0
Файл: gsm.go Проект: Wuyue/Gsm
//初始化redis连接
//传入配置参数
func Init(config ...*Config) {
	config = checkConfig(config)

	for i := 0; i < len(config); i++ {
		var client *redis.Client
		client = redis.New()
		err1 := client.Connect(config[i].Host, config[i].Port)
		log.Println(config[i].Host+":"+strconv.Itoa(int(config[i].Port)), "Connect ...")
		_, err2 := client.Ping()

		if err1 != nil || err2 != nil {
			log.Println("ERROR: Redis Connect failed!")
			os.Exit(0)
		}
		redisSlice = append(redisSlice, client)
		for j := 0; j < len(config[i].Data); j++ {
			structRedis[config[i].Data[j]] = client
		}
	}
}
Пример #20
0
func main() {
	var s string
	var err error

	client = redis.New()

	err = client.Connect(host, port)

	if err != nil {
		log.Fatalf("Connect failed: %s\n", err.Error())
		return
	}

	log.Println("Connected to redis-server.")

	// DEL hello
	log.Printf("DEL hello\n")
	client.Del("hello")

	// SET hello 1
	log.Printf("SET hello 1\n")
	client.Set("hello", 1)

	// INCR hello
	log.Printf("INCR hello\n")
	client.Incr("hello")

	// GET hello
	log.Printf("GET hello\n")
	s, err = client.Get("hello")

	if err != nil {
		log.Fatalf("Could not GET: %s\n", err.Error())
		return
	}

	log.Printf("> hello = %s\n", s)

	client.Quit()
}
Пример #21
0
func main() {
	var err error

	client = redis.New()

	err = client.Connect(host, port)

	if err != nil {
		log.Fatalf("Connect failed: %s\n", err.Error())
		return
	}

	log.Println("Connected to redis-server.")

	// DEL hello
	log.Printf("DEL hello\n")
	client.Command(nil, "DEL", "hello")

	// SET hello 1
	log.Printf("SET hello 1\n")
	client.Command(nil, "SET", "hello", 1)

	// INCR hello
	log.Printf("INCR hello\n")
	client.Command(nil, "INCR", "hello")

	// GET hello
	var i int
	log.Printf("GET hello\n")
	err = client.Command(&i, "GET", "hello")

	if err != nil {
		log.Fatalf("Could not GET: %s\n", err.Error())
		return
	}

	log.Printf("> hello = %d\n", i)

	client.Quit()
}
Пример #22
0
func TestGosexyRedisConnect(t *testing.T) {
	var s string
	var err error

	gosexyRedisClient = redis.New()

	err = gosexyRedisClient.ConnectWithTimeout(host, port, time.Second*1)

	if err != nil {
		t.Fatalf("Connect failed: %v", err)
	}

	s, err = gosexyRedisClient.Ping()

	if err != nil {
		t.Fatalf("Command failed: %v", err)
	}

	if s != "PONG" {
		t.Fatalf("Failed")
	}
}
Пример #23
0
func main() {
	// The remote URL has to be provided as the first command line argument
	remote_host := os.Args[1]
	log.Println("Initializing proxy for: " + remote_host)

	remote, err := url.Parse(remote_host)
	if err != nil {
		panic(err)
	}

	proxy := httputil.NewSingleHostReverseProxy(remote)

	redisClient := redis.New()
	err = redisClient.Connect("127.0.0.1", uint(6379))
	if err != nil {
		panic(err)
	}

	http.HandleFunc("/", handler(proxy, redisClient))
	err = http.ListenAndServe(":8080", nil)
	if err != nil {
		panic(err)
	}
}
Пример #24
0
func outboundHandler(c *eventsocket.Connection) {

	r = redis.New()
	r_err = r.Connect(host, port)
	if r_err != nil {
		log.Fatalf("Connect failed: %s\n", r_err.Error())
	}
	log.Println("Connected to redis-server.")

	fmt.Println("new client:", c.RemoteAddr())

	s := Session{}
	s.c = c

	{
		ev, err := c.Send("connect")
		if err != nil {
			fmt.Println("ERROR: ", err)
			return
		}

		s.callerid = ev.Get("Channel-Caller-Id-Number")
		s.callername = ev.Get("Channel-Caller-Id-Name")
		s.inbound_uuid = ev.Get("Channel-Unique-Id")
	}

	c.Send("linger 5")
	c.Execute("answer", "", true)

	go secretaryCallOut(&s)

	c.Execute("playback", "local_stream://moh", true)

	fmt.Println("playback aborted")

	normal_clearing := false
	{
		ev, err := c.Send("api uuid_getvar " + s.inbound_uuid +
			" hangup_cause")
		if err != nil && ev.Body != "" {
			normal_clearing = true
		}
	}

	hup := false

	if s.secretary_uuid == "" {
		hup = true
	} else {
		ev, err := c.Send("api uuid_exists " + s.secretary_uuid)
		if err != nil || ev.Body == "false" {
			hup = true
		} else {
			// secretary is running
			if normal_clearing {
				// abort the secretary
				fmt.Println("Aborting the secretary")
				c.Send("api uuid_kill " + s.secretary_uuid)
			}
		}
	}

	if hup {
		c.Execute("playback", "misc/sorry.wav", true)
		c.Execute("sleep", "500", true)
		c.Execute("hangup", "", false)
		fmt.Println("hup")
	}

	c.Close()
}
Пример #25
0
func redisConnect(host string, port uint) error {
	var err error
	client = redis.New()
	err = client.Connect(host, port)
	return err
}
Пример #26
0
func outboundHandler(c *eventsocket.Connection) {

	{
		r = redis.New()
		r_err = r.Connect(host, port)
		if r_err != nil {
			log.Fatalf("Connect failed: %s\n", r_err.Error())
		}
		// log.Println("连接redis服务器.")
	}

	fmt.Println("new client:", c.RemoteAddr())

	s := Session{}
	s.c = c

	{
		ev, err := c.Send("connect")
		if err != nil {
			fmt.Println("ERROR: ", err)
			return
		}

		s.caller_id_number = ev.Get("Channel-Caller-Id-Number")
		s.callername = ev.Get("Channel-Caller-Id-Name")
		s.destination_number = ev.Get("Channel-Destination-Number")
		s.inbound_uuid = ev.Get("Channel-Unique-Id")
		// 根据主被叫确定办公电话,客户电话,客户电话状态和分机号码
		s.office_number_type = "湖南好搜"
		s.custom_number_status = "未知"
		if len(s.caller_id_number) == 4 { //主叫4位,内线外呼
			s.call_direction = "呼出"
			s.subnum = s.caller_id_number
			s.custom_number = s.destination_number
			s.office_number, err = r.HGet("rec:"+s.subnum, "phone")
			if err != nil {
				s.office_number = "82088888"
			}
			// 确定分机所属部门及客户电话状态
			if subnum, _ := r.SIsMember("allusers:100", s.subnum); subnum {
				s.subnum_type = "销售"
				if cnum, _ := r.SIsMember("rec:custom", s.custom_number); cnum {
					s.custom_number_status = "custom"
				}
				if cnum, _ := r.SIsMember("rec:warning", s.custom_number); cnum {
					s.custom_number_status = "warning"
				}
				if cnum, _ := r.SIsMember("rec:bother", s.custom_number); cnum {
					s.custom_number_status = "bother"
				}
			}
		} else if len(s.caller_id_number) > 7 { //主叫7位以上号码,1.外线呼入,被叫是好搜; 2.分公司/客户呼入,被叫是客户; 3.外线呼入,被叫是分公司/客户)
			s.call_direction = "呼入"
			s.custom_number = s.caller_id_number
			s.office_number = s.destination_number
			// 确定办公电话类型
			if cnum, _ := r.SIsMember("phone:hnzby", s.caller_id_number); cnum { //主叫电话为周边云号码
				s.call_direction = "呼出"
				s.custom_number = s.destination_number
				s.office_number = s.caller_id_number
				s.office_number_type = "湖南周边云"
			} else if dnum, _ := r.SIsMember("phone:hnzby", s.destination_number); dnum { //被叫电话位周边云号码
				s.office_number_type = "湖南周边云"
			} else {
				s.subnum, err = r.HGet("rec:phone", s.caller_id_number) //通过办公号码找到分机号
				if err != nil {
					s.subnum = "8888"
				}
			}

		} else { //其他异常号码,转前台
			s.call_direction = "未知"
			s.custom_number_status = "异常"
		}

		// 确定客户电话类型
		s.custom_number = clearNum(s.custom_number)
		if validate(s.custom_number, MOBILE) { //是否手机号码
			if cnum, _ := r.SIsMember("phone:hdata:0731", s.custom_number[0:7]); cnum {
				s.custom_number_type = "本地手机"
			} else {
				s.custom_number_type = "外地手机"
				s.custom_number = "0" + s.custom_number //加0
			}

		} else {
			if s.custom_number[0:1] == "0" {
				s.custom_number_type = "外地固话"
			} else {
				s.custom_number_type = "本地固话"
			}
		}
		r.Quit()
		// log.Println("断开redis服务器.")
	}
	// 录音文件名
	year := time.Now().Format("2006")
	month := time.Now().Format("01")
	day := time.Now().Format("02")
	s.rec_file = fmt.Sprintf("/mnt/stone/%s/%s/%s/%s_%s_%s.wav", year, month, day, s.caller_id_number, s.destination_number, s.inbound_uuid)
	// 流程控制
	// 1. 是否分公司/客户号码,送到相应网关
	// 2. 是否不识别的主/被叫号码(用 call_direction="未知" 来表示)
	// 3. 呼出号码处理
	//    3.1 是否销售分机外呼 --> 是否设置了电话号码状态 --> 播放相应提示语音,DTMF按键 --> 挂机
	//    3.2 不满足上述条件,则直接外呼
	// 4. 呼入号码处理
	//    4.1 是否有对应的分机号码 -->(分机是否在线) --> 直接转分机
	//    4.2 不满足上述条件,转前台总机

	ringback := "ringback=file_string://" + WAIT
	c.Execute("set", ringback, false)
	c.Execute("set", "hangup_after_bridge=true", false)
	// c.Send("linger 5")
	c.Execute("answer", "", true)
	// c.Execute("playback", "local_stream://moh", true)
	cmd := "user/[email protected]"
	if s.office_number_type != "湖南好搜" {
		if s.office_number_type == "湖南周边云" {
			callerIDNumber := "effective_caller_id_number=" + s.caller_id_number
			c.Execute("set", callerIDNumber, false)
			if s.call_direction == "呼入" {
				cmd = "sofia/gateway/hnzby/" + s.destination_number
			} else if s.call_direction == "呼出" {
				cmd = "sofia/gateway/serv36/" + s.destination_number
			}
		}
	} else if s.call_direction == "呼出" {
		if s.subnum_type == "销售" {
			if s.custom_number_status == "warning" || s.custom_number_status == "custom" || s.custom_number_status == "bother" {

				log.Println("销售电话")
				sound := "/usr/share/freeswitch/sounds/" + s.custom_number_status + ".wav"
				c.Execute("playback", sound, true)
				// started := time.Now()
				// digit := ""
				c.Execute("hungup", "", true)
				// for time.Since(started).Seconds() < 60 && digit == "" {

				//	ev, err := c.Send("api uuid_exists " + s.inbound_uuid)
				//	if err != nil || ev.Body == "false" {
				//		break
				//	}

				//	digit = playAndGetOneDigit(
				//		sound,
				//		c, s.inbound_uuid)
				// }

				// if digit != "1" {
				//	c.Send("api uuid_break " + s.inbound_uuid)
				//	c.Close()
				//	return
				//	c.Send("api uuid_break " + s.inbound_uuid)
				c.Close()
				return
			}
		}
		c.Execute("set", "RECORD_ANSWER_REQ=true", false)
		c.Execute("record_session", s.rec_file, false)
		callerIDNumber := "effective_caller_id_number=" + s.office_number
		c.Execute("set", callerIDNumber, false)
		cmd = "{ignore_early_media=false}sofia/gateway/serv36/" + s.custom_number
	} else if s.call_direction == "呼入" {
		c.Execute("set", "RECORD_ANSWER_REQ=true", false)
		c.Execute("record_session", s.rec_file, false)
		cmd = "user/" + s.subnum + "@192.168.36.1"
	} else {
		c.Execute("set", "RECORD_ANSWER_REQ=true", false)
		c.Execute("record_session", s.rec_file, false)
	}

	log.Println(s.caller_id_number, "-->", s.destination_number, s.call_direction, " 分机:", s.subnum, ", 办公电话:", s.office_number, ", 电话所属:", s.office_number_type)

	_, err := c.Execute("bridge", cmd, false)
	if err != nil {
		// hup = true
		log.Println("Error calling out: ", err)
	} else {
		// c.Send("api uuid_break " + s.inbound_uuid) //可能有挂断异常的情况,强行挂断。
		c.Send("api uuid_kill " + s.inbound_uuid)
		log.Println(s.caller_id_number, "-->", s.destination_number, "挂断")
	}

	// go secretaryCallOut(&s)

	// c.Execute("playback", "local_stream://moh", true)

	// fmt.Println("playback aborted")

	// normal_clearing := false
	// {
	//	ev, err := c.Send("api uuid_getvar " + s.inbound_uuid +
	//		" hangup_cause")
	//	if err != nil && ev.Body != "" {
	//		normal_clearing = true
	//	}
	// }

	// hup := false

	// if s.secretary_uuid == "" {
	//	hup = true
	// } else {
	//	ev, err := c.Send("api uuid_exists " + s.secretary_uuid)
	//	if err != nil || ev.Body == "false" {
	//		hup = true
	//	} else {
	//		// secretary is running
	//		if normal_clearing {
	//			// abort the secretary
	//			fmt.Println("Aborting the secretary")
	//			c.Send("api uuid_kill " + s.secretary_uuid)
	//		}
	//	}
	// }

	// if hup {
	//	c.Execute("playback", "misc/sorry.wav", true)
	//	c.Execute("sleep", "500", true)
	//	c.Execute("hangup", "", false)
	//	fmt.Println("hup")
	// }

	c.Close()
}