当前位置: 首页>>代码示例>>Golang>>正文


Golang Event.GetReqType方法代码示例

本文整理汇总了Golang中github.com/cgrates/cgrates/engine.Event.GetReqType方法的典型用法代码示例。如果您正苦于以下问题:Golang Event.GetReqType方法的具体用法?Golang Event.GetReqType怎么用?Golang Event.GetReqType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cgrates/cgrates/engine.Event的用法示例。


在下文中一共展示了Event.GetReqType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: onChannelHangupComplete

func (sm *FSSessionManager) onChannelHangupComplete(ev engine.Event) {
	if ev.GetReqType(utils.META_DEFAULT) == utils.META_NONE { // Do not process this request
		return
	}
	var s *Session
	for i := 0; i < 2; i++ { // Protect us against concurrency, wait a couple of seconds for the answer to be populated before we process hangup
		s = sm.sessions.getSession(ev.GetUUID())
		if s != nil {
			break
		}
		time.Sleep(time.Duration(i+1) * time.Second)
	}
	if s != nil { // Handled by us, cleanup here
		if err := sm.sessions.removeSession(s, ev); err != nil {
			utils.Logger.Err(err.Error())
		}
	}
	if sm.cfg.CreateCdr {
		sm.ProcessCdr(ev.AsStoredCdr(config.CgrConfig().DefaultTimezone))
	}
	var reply string
	attrRU := utils.AttrRLsResourceUsage{
		ResourceUsageID: ev.GetUUID(),
		Event:           ev.(FSEvent).AsMapStringInterface(sm.timezone),
		RequestedUnits:  1,
	}
	if sm.rls != nil {
		if err := sm.rls.Call("RLsV1.TerminateResourceUsage", attrRU, &reply); err != nil {
			utils.Logger.Err(fmt.Sprintf("<SM-FreeSWITCH> RLs API error: %s", err.Error()))
		}
	}
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:32,代码来源:fssessionmanager.go

示例2: onChannelAnswer

func (sm *FSSessionManager) onChannelAnswer(ev engine.Event, connId string) {
	if ev.GetReqType(utils.META_DEFAULT) == utils.META_NONE { // Do not process this request
		return
	}
	if ev.MissingParameter() {
		sm.DisconnectSession(ev, connId, MISSING_PARAMETER)
	}
	s := NewSession(ev, connId, sm)
	if s != nil {
		sm.sessions = append(sm.sessions, s)
	}
}
开发者ID:henrylee2cn,项目名称:cgrates,代码行数:12,代码来源:fssessionmanager.go

示例3: onChannelPark

func (sm *FSSessionManager) onChannelPark(ev engine.Event, connId string) {
	fsev := ev.(FSEvent)
	if ev.GetReqType(utils.META_DEFAULT) == utils.META_NONE || fsev[IGNOREPARK] == "true" { // Do not process this request
		return
	}
	var maxCallDuration float64 // This will be the maximum duration this channel will be allowed to last
	if err := sm.rater.Call("Responder.GetDerivedMaxSessionTime", ev.AsStoredCdr(config.CgrConfig().DefaultTimezone), &maxCallDuration); err != nil {
		utils.Logger.Err(fmt.Sprintf("<SM-FreeSWITCH> Could not get max session time for %s, error: %s", ev.GetUUID(), err.Error()))
	}
	if maxCallDuration != -1 { // For calls different than unlimited, set limits
		maxCallDur := time.Duration(maxCallDuration)
		if maxCallDur <= sm.cfg.MinCallDuration {
			//utils.Logger.Info(fmt.Sprintf("Not enough credit for trasferring the call %s for %s.", ev.GetUUID(), cd.GetKey(cd.Subject)))
			sm.unparkCall(ev.GetUUID(), connId, ev.GetCallDestNr(utils.META_DEFAULT), INSUFFICIENT_FUNDS)
			return
		}
		sm.setMaxCallDuration(ev.GetUUID(), connId, maxCallDur)
	}
	// ComputeLcr
	if ev.ComputeLcr() {
		cd, err := fsev.AsCallDescriptor()
		cd.CgrID = fsev.GetCgrId(sm.Timezone())
		if err != nil {
			utils.Logger.Info(fmt.Sprintf("<SM-FreeSWITCH> LCR_PREPROCESS_ERROR: %s", err.Error()))
			sm.unparkCall(ev.GetUUID(), connId, ev.GetCallDestNr(utils.META_DEFAULT), SYSTEM_ERROR)
			return
		}
		var lcr engine.LCRCost
		if err = sm.Rater().Call("Responder.GetLCR", &engine.AttrGetLcr{CallDescriptor: cd}, &lcr); err != nil {
			utils.Logger.Info(fmt.Sprintf("<SM-FreeSWITCH> LCR_API_ERROR: %s", err.Error()))
			sm.unparkCall(ev.GetUUID(), connId, ev.GetCallDestNr(utils.META_DEFAULT), SYSTEM_ERROR)
		}
		if lcr.HasErrors() {
			lcr.LogErrors()
			sm.unparkCall(ev.GetUUID(), connId, ev.GetCallDestNr(utils.META_DEFAULT), SYSTEM_ERROR)
			return
		}
		if supps, err := lcr.SuppliersSlice(); err != nil {
			utils.Logger.Info(fmt.Sprintf("<SM-FreeSWITCH> LCR_ERROR: %s", err.Error()))
			sm.unparkCall(ev.GetUUID(), connId, ev.GetCallDestNr(utils.META_DEFAULT), SYSTEM_ERROR)
			return
		} else {
			fsArray := SliceAsFsArray(supps)
			if _, err = sm.conns[connId].SendApiCmd(fmt.Sprintf("uuid_setvar %s %s %s\n\n", ev.GetUUID(), utils.CGR_SUPPLIERS, fsArray)); err != nil {
				utils.Logger.Info(fmt.Sprintf("<SM-FreeSWITCH> LCR_ERROR: %s", err.Error()))
				sm.unparkCall(ev.GetUUID(), connId, ev.GetCallDestNr(utils.META_DEFAULT), SYSTEM_ERROR)
			}
		}
	}
	sm.unparkCall(ev.GetUUID(), connId, ev.GetCallDestNr(utils.META_DEFAULT), AUTH_OK)
}
开发者ID:iwada,项目名称:cgrates,代码行数:51,代码来源:fssessionmanager.go

示例4: onChannelHangupComplete

func (sm *FSSessionManager) onChannelHangupComplete(ev engine.Event) {
	if ev.GetReqType(utils.META_DEFAULT) == utils.META_NONE { // Do not process this request
		return
	}
	var s *Session
	for i := 0; i < 2; i++ { // Protect us against concurrency, wait a couple of seconds for the answer to be populated before we process hangup
		s = sm.sessions.getSession(ev.GetUUID())
		if s != nil {
			break
		}
		time.Sleep(time.Duration(i+1) * time.Second)
	}
	if s != nil { // Handled by us, cleanup here
		if err := sm.sessions.removeSession(s, ev); err != nil {
			utils.Logger.Err(err.Error())
		}
	}
	if sm.cfg.CreateCdr {
		sm.ProcessCdr(ev.AsStoredCdr(config.CgrConfig().DefaultTimezone))
	}
}
开发者ID:iwada,项目名称:cgrates,代码行数:21,代码来源:fssessionmanager.go

示例5: onChannelHangupComplete

func (sm *FSSessionManager) onChannelHangupComplete(ev engine.Event) {
	if ev.GetReqType(utils.META_DEFAULT) == utils.META_NONE { // Do not process this request
		return
	}
	if sm.cfg.CreateCdr {
		go sm.ProcessCdr(ev.AsStoredCdr(config.CgrConfig().DefaultTimezone))
	}
	var s *Session
	for i := 0; i < 2; i++ { // Protect us against concurrency, wait a couple of seconds for the answer to be populated before we process hangup
		s = sm.GetSession(ev.GetUUID())
		if s != nil {
			break
		}
		time.Sleep(time.Duration(i+1) * time.Second)
	}
	if s == nil { // Not handled by us
		return
	}
	sm.RemoveSession(s.eventStart.GetUUID()) // Unreference it early so we avoid concurrency
	if err := s.Close(ev); err != nil {      // Stop loop, refund advanced charges and save the costs deducted so far to database
		utils.Logger.Err(err.Error())
	}
}
开发者ID:henrylee2cn,项目名称:cgrates,代码行数:23,代码来源:fssessionmanager.go


注:本文中的github.com/cgrates/cgrates/engine.Event.GetReqType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。