本文整理匯總了Golang中github.com/fiorix/go-eventsocket/eventsocket.Event類的典型用法代碼示例。如果您正苦於以下問題:Golang Event類的具體用法?Golang Event怎麽用?Golang Event使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Event類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: handleUseJoinedEvent
func handleUseJoinedEvent(e *eventsocket.Event) VoiceUserJoinedEvent {
memberId := getMemberIdFromEvent(e)
callerIdNum := getCallerIdNumFromEvent(e)
callerIdName := getCallerIdNameFromEvent(e)
speak := getSpeakFromEvent(e)
muted := isUserMuted(speak)
talking := isUserTalking(e)
confName := e.Get("Conference-Name")
// confSize := e.Get("Conference-Size")
// voiceUserId := callerIdName
globalAudio := isUserJoinedThoughGlobalAudio(callerIdName)
voiceUser := VoiceUserJoinedEvent{}
if globalAudio != true {
user, err := getUser(callerIdName)
if err != nil {
voiceUser := VoiceUserJoinedEvent{}
voiceUser.ConferenceId = confName
voiceUser.VoiceUserId = user.UserId
voiceUser.CallerIdNum = callerIdNum
voiceUser.CallerIdName = user.Username
voiceUser.Muted = muted
voiceUser.Talking = talking
voiceUser.Locked = false
voiceUser.UserId = memberId
}
}
return voiceUser
}
示例2: isUserTalking
func isUserTalking(e *eventsocket.Event) bool {
talk, err := strconv.ParseBool(e.Get("Talking"))
talking := false
if err != nil {
if talk {
talking = false
} else {
talking = true
}
}
return talking
}
示例3: AddEvent
// AddEvent parses a FreeSWITCH EventSocket event and merges contained information into the FaxResult
func (f *FaxResult) AddEvent(ev *eventsocket.Event) {
switch ev.Get("Event-Name") {
case "CHANNEL_CALLSTATE":
// Call state has changed
callstate := ev.Get("Channel-Call-State")
f.sessionlog.Log("Call state change:", callstate)
if callstate == "ACTIVE" {
f.StartTs = time.Now()
}
if callstate == "HANGUP" {
f.EndTs = time.Now()
f.Hangupcause = ev.Get("Hangup-Cause")
}
case "CUSTOM":
// Fax results have changed
action := ""
switch ev.Get("Event-Subclass") {
case "spandsp::rxfaxnegociateresult":
fallthrough
case "spandsp::txfaxnegociateresult":
f.NegotiateCount++
if ecm := ev.Get("Fax-Ecm-Used"); ecm == "on" {
f.Ecm = true
}
f.RemoteID = ev.Get("Fax-Remote-Station-Id")
if rate, err := strconv.ParseUint(ev.Get("Fax-Transfer-Rate"), 10, 0); err == nil {
f.TransferRate = uint(rate)
}
f.sessionlog.Log(fmt.Sprintf("Remote ID: \"%v\", Transfer Rate: %v, ECM=%v", f.RemoteID, f.TransferRate, f.Ecm))
case "spandsp::rxfaxpageresult":
action = "received"
fallthrough
case "spandsp::txfaxpageresult":
if action == "" {
action = "sent"
}
// A page was transferred
if pages, err := strconv.ParseUint(ev.Get("Fax-Document-Transferred-Pages"), 10, 0); err == nil {
f.TransferredPages = uint(pages)
}
pr := new(PageResult)
pr.Page = f.TransferredPages
if badrows, err := strconv.ParseUint(ev.Get("Fax-Bad-Rows"), 10, 0); err == nil {
pr.BadRows = uint(badrows)
}
pr.EncodingName = ev.Get("Fax-Encoding-Name")
if imgsize, err := parseResolution(ev.Get("Fax-Image-Pixel-Size")); err == nil {
pr.ImagePixelSize = *imgsize
}
if filesize, err := parseResolution(ev.Get("Fax-File-Image-Pixel-Size")); err == nil {
pr.FilePixelSize = *filesize
}
if imgres, err := parseResolution(ev.Get("Fax-Image-Resolution")); err == nil {
pr.ImageResolution = *imgres
}
if fileres, err := parseResolution(ev.Get("Fax-File-Image-Resolution")); err == nil {
pr.FileResolution = *fileres
}
if size, err := strconv.ParseUint(ev.Get("Fax-Image-Size"), 10, 0); err == nil {
pr.ImageSize = uint(size)
}
if badrowrun, err := strconv.ParseUint(ev.Get("Fax-Longest-Bad-Row-Run"), 10, 0); err == nil {
pr.LongestBadRowRun = uint(badrowrun)
}
f.PageResults = append(f.PageResults, *pr)
f.sessionlog.Log(fmt.Sprintf("Page %d %v: %v", f.TransferredPages, action, *pr))
case "spandsp::rxfaxresult":
fallthrough
case "spandsp::txfaxresult":
if totalpages, err := strconv.ParseUint(ev.Get("Fax-Document-Total-Pages"), 10, 0); err == nil {
f.TotalPages = uint(totalpages)
}
if transferredpages, err := strconv.ParseUint(ev.Get("Fax-Document-Transferred-Pages"), 10, 0); err == nil {
f.TransferredPages = uint(transferredpages)
}
if ecm := ev.Get("Fax-Ecm-Used"); ecm == "on" {
f.Ecm = true
}
f.RemoteID = ev.Get("Fax-Remote-Station-Id")
if resultcode, err := strconv.Atoi(ev.Get("Fax-Result-Code")); err == nil {
f.ResultCode = resultcode
}
f.ResultText = ev.Get("Fax-Result-Text")
if ev.Get("Fax-Success") == "1" {
f.Success = true
}
if rate, err := strconv.ParseUint(ev.Get("Fax-Transfer-Rate"), 10, 0); err == nil {
f.TransferRate = uint(rate)
}
}
}
//.........這裏部分代碼省略.........
示例4: getSpeakFromEvent
func getSpeakFromEvent(e *eventsocket.Event) string {
return e.Get("Speak")
}
示例5: getRecordFilenameFromEvent
func getRecordFilenameFromEvent(e *eventsocket.Event) string {
return e.Get("Path")
}
示例6: getCallerIdNameFromEvent
func getCallerIdNameFromEvent(e *eventsocket.Event) string {
return e.Get("Caller-Caller-ID-Name")
}
示例7: getCallerIdNumFromEvent
func getCallerIdNumFromEvent(e *eventsocket.Event) string {
return e.Get("Caller-Caller-ID-Number")
}
示例8: getMemberIdFromEvent
func getMemberIdFromEvent(e *eventsocket.Event) string {
return e.Get("Member-ID")
}