本文整理匯總了Golang中github.com/fiorix/go-eventsocket/eventsocket.Connection.Close方法的典型用法代碼示例。如果您正苦於以下問題:Golang Connection.Close方法的具體用法?Golang Connection.Close怎麽用?Golang Connection.Close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/fiorix/go-eventsocket/eventsocket.Connection
的用法示例。
在下文中一共展示了Connection.Close方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SetSoftmodemFallback
// SetSoftmodemFallback saves the given softmodem fallback setting for a caller id
// to FreeSWITCH's mod_db
func SetSoftmodemFallback(c *eventsocket.Connection, cidnum string, enabled bool) error {
if !Config.Freeswitch.SoftmodemFallback || cidnum == "" {
return nil
}
var err error
if c == nil {
c, err = eventsocket.Dial(Config.Freeswitch.Socket, Config.Freeswitch.Password)
if err != nil {
return err
}
defer c.Close()
}
return FreeSwitchDBInsert(c, modDbFallbackRealm, cidnum, fmt.Sprintf("%d", time.Now().Unix()))
}
示例2: GetSoftmodemFallback
// GetSoftmodemFallback checks if fallback to SpanDSP's softmodem (no T.38)
// should be enabled for the given callerid number
func GetSoftmodemFallback(c *eventsocket.Connection, cidnum string) (bool, error) {
if !Config.Freeswitch.SoftmodemFallback || cidnum == "" {
return false, nil
}
var err error
if c == nil {
c, err = eventsocket.Dial(Config.Freeswitch.Socket, Config.Freeswitch.Password)
if err != nil {
return false, err
}
defer c.Close()
}
exists, err := FreeSwitchDBExists(c, modDbFallbackRealm, cidnum)
if err != nil {
return false, err
}
return exists, nil
}
示例3: outboundHandler
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()
}
示例4: outboundHandler
//.........這裏部分代碼省略.........
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)
示例5: handler
//.........這裏部分代碼省略.........
sessionlog.Log(err)
return
}
filename := filepath.Join(recvqDir, fmt.Sprintf(recvqFileFormat, seq))
filenameAbs := filepath.Join(gofaxlib.Config.Hylafax.Spooldir, filename)
sessionlog.Log("Rxfax to", filenameAbs)
if disableT38 {
c.Execute("set", "fax_enable_t38=false", true)
} else {
c.Execute("set", "fax_enable_t38_request=true", true)
c.Execute("set", "fax_enable_t38=true", true)
}
c.Execute("set", fmt.Sprintf("fax_ident=%s", csi), true)
c.Execute("rxfax", filenameAbs, true)
result := gofaxlib.NewFaxResult(channelUUID, sessionlog)
es := gofaxlib.NewEventStream(c)
pages := result.TransferredPages
EventLoop:
for {
select {
case ev := <-es.Events():
if ev.Get("Content-Type") == "text/disconnect-notice" {
sessionlog.Log("Received disconnect message")
//c.Close()
//break EventLoop
} else {
result.AddEvent(ev)
if result.Hangupcause != "" {
c.Close()
break EventLoop
}
if pages != result.TransferredPages {
pages = result.TransferredPages
if device != nil {
gofaxlib.Faxq.ReceiveStatus(device.Name, "P")
}
}
}
case err := <-es.Errors():
if err.Error() == "EOF" {
sessionlog.Log("Event socket client disconnected")
} else {
sessionlog.Log("Error:", err)
}
break EventLoop
case _ = <-e.killChan:
sessionlog.Log("Kill reqeust received, destroying channel")
c.Send(fmt.Sprintf("api uuid_kill %v", channelUUID))
c.Close()
return
}
}
if device != nil {
gofaxlib.Faxq.ReceiveStatus(device.Name, "D")
}
sessionlog.Log(fmt.Sprintf("Success: %v, Hangup Cause: %v, Result: %v", result.Success, result.Hangupcause, result.ResultText))
xfl := gofaxlib.NewXFRecord(result)
xfl.Modem = usedDevice