mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-12 02:26:26 +05:00
new un-park command
This commit is contained in:
@@ -131,9 +131,8 @@ func (sm *FSSessionManager) DisconnectSession(s *Session) {
|
||||
}
|
||||
|
||||
// Sends the transfer command to unpark the call to freeswitch
|
||||
func (sm *FSSessionManager) UnparkCall(uuid, call_dest_nb, reply string) {
|
||||
fmt.Fprint(sm.conn, fmt.Sprintf("api uuid_setvar %s cgr_notify %s\n\n", uuid, reply))
|
||||
fmt.Fprint(sm.conn, fmt.Sprintf("api uuid_transfer %s %s\n\n", uuid, call_dest_nb))
|
||||
func (sm *FSSessionManager) UnparkCall(uuid, reply string) {
|
||||
fmt.Fprint(sm.conn, fmt.Sprintf("api uuid_transfer %s 'set:cgr_notify=%s' inline\n\n", uuid, reply))
|
||||
}
|
||||
|
||||
// Called on freeswitch's hearbeat event
|
||||
|
||||
@@ -46,7 +46,7 @@ func (rsd *SessionDelegate) OnChannelPark(ev Event, sm SessionManager) {
|
||||
return
|
||||
}
|
||||
if ev.MissingParameter() {
|
||||
sm.UnparkCall(ev.GetUUID(), ev.GetCallDestNb(), MISSING_PARAMETER)
|
||||
sm.UnparkCall(ev.GetUUID(), MISSING_PARAMETER)
|
||||
}
|
||||
cd := timespans.CallDescriptor{
|
||||
Direction: ev.GetDirection(),
|
||||
@@ -60,15 +60,15 @@ func (rsd *SessionDelegate) OnChannelPark(ev Event, sm SessionManager) {
|
||||
err = rsd.Connector.GetMaxSessionTime(cd, &remainingSeconds)
|
||||
if err != nil {
|
||||
timespans.Logger.Err(fmt.Sprintf("Could not get max session time for %v: %v", ev.GetUUID(), err))
|
||||
sm.UnparkCall(ev.GetUUID(), ev.GetCallDestNb(), SYSTEM_ERROR)
|
||||
sm.UnparkCall(ev.GetUUID(), SYSTEM_ERROR)
|
||||
return
|
||||
}
|
||||
if remainingSeconds == 0 {
|
||||
timespans.Logger.Info(fmt.Sprintf("Not enough credit for trasferring the call %v.", ev.GetUUID()))
|
||||
sm.UnparkCall(ev.GetUUID(), ev.GetCallDestNb(), INSUFFICIENT_FUNDS)
|
||||
sm.UnparkCall(ev.GetUUID(), INSUFFICIENT_FUNDS)
|
||||
return
|
||||
}
|
||||
sm.UnparkCall(ev.GetUUID(), ev.GetCallDestNb(), AUTH_OK)
|
||||
sm.UnparkCall(ev.GetUUID(), AUTH_OK)
|
||||
}
|
||||
|
||||
func (rsd *SessionDelegate) OnChannelAnswer(ev Event, s *Session) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
|
||||
type SessionManager interface {
|
||||
DisconnectSession(*Session)
|
||||
UnparkCall(string, string, string)
|
||||
UnparkCall(string, string)
|
||||
GetSessionDelegate() *SessionDelegate
|
||||
GetDbLogger() timespans.DataStorage
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user