說真的,以目前的食譜要來設計這樣的需求是足夠了,先來看看流程圖
簡單講就是,判斷是不是有人已經用同一支電話登入了,如果有,就將它登出,然後再用新的登入,否則直接登入。
底下直接寫範例(我也還在研讀當中):
[HotDesking]
exten => 7000,1,Verbose(2,Attempting logoff from device ${CHANNEL(peername)})
same => n,Set(PeerName=${CHANNEL(peername)})
same => n,Set(CurrentExtension=${DB(HotDesk/${PeerName})})
same => n,GoSubIf($[${EXISTS(${CurrentExtension})}]? subDeviceLogoff,1(${PeerName},${CurrentExtension}):loggedoff)
same => n,GotoIf($[${GOSUB_RETVAL} = 0]?loggedoff)
same => n,Playback(an-error-has-occurred)
same => n,Hangup()
same => n(loggedoff),Playback(silence/1&agent-loggedoff)
same => n,Hangup()
上面這段設定分機號碼 7000 用來登出裝置,
- 裝置以 ${PeerName} = ${CHANNEL(peername)} 表示,
- 分機號碼以 ${DB(HotDesk/${PeerName})} 表示
底下 71XX 則表示先登出現有的分機號碼再登入
exten => _71XX,1,Verbose(2,Attempting to login device ${CHANNEL(peername)} to extension ${EXTEN:1})
same => n,Set(NewPeerName=${CHANNEL(peername)})
same => n,Set(NewExtension=${EXTEN:1})
same => n,Set(ExistingExtension=${DB(HotDesk/${NewPeerName})})
same => n,GotoIf($[${EXISTS(${ExistingExtension})}]?get_existing_device)
same => n(check_device),NoOp()
same => n,Set(ExistingDevice=${DB(HotDesk/${NewExtension})})
same => n,GotoIf($[${EXISTS(${ExistingDevice})}]?get_existing_extension)
same => n,NoOp(Nothing to logout)
same => n,Goto(login)
same => n(get_existing_device),NoOp()
same => n,Set(ExistingDevice=${DB(HotDesk/${ExistingExtension})})
same => n,GotoIf($[${ISNULL(${ExistingDevice})}]?login)
same => n,GoSub(subDeviceLogoff,1(${ExistingDevice},${ExistingExtension}))
same => n,GotoIf($[${GOSUB_RETVAL} = 0]?check_device)
same => n,Playback(silence/1&an-error-has-occurred)
same => n,Hangup()
same => n(get_existing_extension),NoOp()
same => n,Set(ExistingExtension=${DB(HotDesk/${ExistingDevice})})
same => n,GoSubIf($[${EXISTS(${ExistingExtension})}]? subDeviceLogoff,1(${ExistingDevice},${ExistingExtension}):remove_device)
same => n,GotoIf($[${GOSUB_RETVAL} = 0]?loggedoff)
same => n,Playback(silence/1&an-error-has-occurred)
same => n,Hangup()
same => n(remove_device),NoOp()
same => n,Set(Result=${DB_DELETE(HotDesk/${ExistingDevice})})
same => n,Goto(loggedoff)
same => n(loggedoff),Verbose(2,Existing device and extensions have been logged off prior to login)
same => n(login),Verbose(2,Now logging in extension ${NewExtension} to device ${NewPeerName})
same => n,GoSub(subDeviceLogin,1(${NewPeerName},${NewExtension}))
same => n,GotoIf($[${GOSUB_RETVAL} = 0]?login_ok)
same => n,Playback(silence/1&an-error-has-occurred)
same => n,Hangup()
same => n(login_ok),Playback(silence/1&agent-loginok)
same => n,Hangup()
exten => subDeviceLogoff,1,NoOp()
same => n,Set(LOCAL(PeerName)=${ARG1})
same => n,Set(LOCAL(Extension)=${ARG2})
same => n,ExecIf($[${ISNULL(${LOCAL(PeerName)})} | ${ISNULL(${LOCAL(Extension)})}]?Return(-1))
same => n,Set(PeerNameResult=${DB_DELETE(HotDesk/${LOCAL(PeerName)})})
same => n,Set(ExtensionResult=${DB_DELETE(HotDesk/${LOCAL(Extension)})})
same => n,Return(0)
exten => subDeviceLogin,1,NoOp()
same => n,Set(LOCAL(PeerName)=${ARG1})
same => n,Set(LOCAL(Extension)=${ARG2})
same => n,ExecIf($[${ISNULL(${LOCAL(PeerName)})} | ${ISNULL(${LOCAL(Extension)})}]?Return(-1))
same => n,Set(DB(HotDesk/${LOCAL(PeerName)})=${LOCAL(Extension)})
same => n,Set(DB(HotDesk/${LOCAL(Extension)})=${LOCAL(PeerName)})
same => n,Set(ReturnResult=${IF($[${DB_EXISTS(HotDesk/${LOCAL(PeerName)})} & ${DB_EXISTS(HotDesk/${LOCAL(Extension)})}]?0:-1)})
same => n,Return(${ReturnResult})
0 意見:
張貼留言