本文整理匯總了Golang中github.com/fiorix/go-eventsocket/eventsocket.Connection.ReadEvent方法的典型用法代碼示例。如果您正苦於以下問題:Golang Connection.ReadEvent方法的具體用法?Golang Connection.ReadEvent怎麽用?Golang Connection.ReadEvent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/fiorix/go-eventsocket/eventsocket.Connection
的用法示例。
在下文中一共展示了Connection.ReadEvent方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: playAndGetOneDigit
func playAndGetOneDigit(
sound string,
c *eventsocket.Connection,
uuid string) string {
c.Send("filter Unique-ID " + uuid)
c.Send("event plain CHANNEL_EXECUTE_COMPLETE")
{
_, err := c.ExecuteUUID(
uuid,
"play_and_get_digits",
"1 1 1 400 # "+
sound+" silence_stream://250 result \\d")
if err != nil {
fmt.Println("Error executing play_and_get_digits: ",
err)
return ""
}
}
finished := false
ret := ""
for !finished {
ev, err := c.ReadEvent()
if err != nil {
finished = true
} else {
if ev.Get("Event-Name") ==
"CHANNEL_EXECUTE_COMPLETE" &&
ev.Get("Application") == "play_and_get_digits" {
ret = ev.Get("Variable_result")
finished = true
}
}
}
c.Send("noevents")
c.Send("filter delete Unique-ID " + uuid)
return ret
}
示例2: handler
func handler(c *eventsocket.Connection) {
fmt.Println("new client:", c.RemoteAddr())
c.Send("connect")
c.Send("myevents")
c.Execute("answer", "", false)
ev, err := c.Execute("playback", audioFile, true)
if err != nil {
log.Fatal(err)
}
ev.PrettyPrint()
for {
ev, err = c.ReadEvent()
if err != nil {
log.Fatal(err)
}
fmt.Println("\nNew event")
ev.PrettyPrint()
if ev.Get("Application") == "playback" {
if ev.Get("Application-Response") == "FILE PLAYED" {
c.Send("exit")
}
}
}
}