本文整理汇总了Golang中github.com/cgrates/cgrates/engine.Event.GetSessionIds方法的典型用法代码示例。如果您正苦于以下问题:Golang Event.GetSessionIds方法的具体用法?Golang Event.GetSessionIds怎么用?Golang Event.GetSessionIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cgrates/cgrates/engine.Event
的用法示例。
在下文中一共展示了Event.GetSessionIds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: DisconnectSession
func (self *KamailioSessionManager) DisconnectSession(ev engine.Event, connId, notify string) error {
sessionIds := ev.GetSessionIds()
disconnectEv := &KamSessionDisconnect{Event: CGR_SESSION_DISCONNECT, HashEntry: sessionIds[0], HashId: sessionIds[1], Reason: notify}
if err := self.conns[connId].Send(disconnectEv.String()); err != nil {
utils.Logger.Err(fmt.Sprintf("<SM-Kamailio> Failed sending disconnect request, error %s, connection id: %s", err.Error(), connId))
return err
}
return nil
}
示例2: DisconnectSession
// Disconnects the session
func (osm *OsipsSessionManager) DisconnectSession(ev engine.Event, connId, notify string) error {
sessionIds := ev.GetSessionIds()
if len(sessionIds) != 2 {
errMsg := fmt.Sprintf("Failed disconnecting session for event: %+v, notify: %s, dialogId: %v", ev, notify, sessionIds)
utils.Logger.Err(fmt.Sprintf("<SM-OpenSIPS> " + errMsg))
return errors.New(errMsg)
}
cmd := fmt.Sprintf(":dlg_end_dlg:\n%s\n%s\n\n", sessionIds[0], sessionIds[1])
if reply, err := osm.miConn.SendCommand([]byte(cmd)); err != nil {
utils.Logger.Err(fmt.Sprintf("<SM-OpenSIPS> Failed disconnecting session for event: %+v, notify: %s, dialogId: %v, error: <%s>", ev, notify, sessionIds, err))
return err
} else if !bytes.HasPrefix(reply, []byte("200 OK")) {
errStr := fmt.Sprintf("Failed disconnecting session for event: %+v, notify: %s, dialogId: %v", ev, notify, sessionIds)
utils.Logger.Err("<SM-OpenSIPS> " + errStr)
return errors.New(errStr)
}
return nil
}