so i need to use a variable from a context that a caller called to the context that the called party uses, so i have a code like this
[calledContext]
exten => s,1,goto(waits)
same => n,goto(playmessage)
same => n(waits),set(a=0)
same => n(waits2),wait(5)
same => n,GotoIf($[${a} = 0]?waits2:hang)
same => n(playmessage),noop(${randomId})
same => n(hang),hangup();
[callerContext]
exten => 012345,1,Noop()
same => n,set(randomId=523)
same => n,Dial(SIP/09201234567,20,G(calledContext^s^1)g)
same => n,hangup()
heres my problem, in the calledContext context, when i use noop() on ${randomId}, nothing is displayed, how do i pass the value of the randomId from callerContext to calledContext?
SHARED is not what you want here.
The G option in Dial is one of those fun options that sends the two channels involved in the Dial operation to different places. Both are going to be sent to the Context/Extension you specified, which - given the names of the contexts - is probably not what you want. The called party gets sent to priority+1; the calling party priority.
That is, I'd expect the called party to start executing at calledContext,s,2 and the calling party to start executing at calledContext,s,1. But that's ancillary to your issue.
A variable set on an inbound channel can be passed to the channels it dials using channel variable inheritance. That is:
exten => 012345,1,Noop()
; Using a single underbar will set randomId on all channels this
; channel creates, but will not continue to propagate further
same => n,set(_randomId=523)
; Using two underbars will cause the variable to always propagate
same => n,set(__someOtherId=111)
same => n,Dial(SIP/09201234567,20,G(calledContext^s^1)g)
same => n,hangup()
Using the _ or __ will cause the variables to be set on the called party. If you want the variables to continue to propagate to channels the called party may also call, then use __.
Asterisk use concepts of CHANNEL or leg.
So in your call you have 2 channel, each one have independent variables and control structure
You can see name of bridged channels by BRIDGEPEER
http://www.voip-info.org/wiki/view/Asterisk+Detailed+Variable+List
You can get variables of other channel by using function SHARED maybe.
http://www.voip-info.org/wiki/view/Asterisk+func+shared
For see variables set in current channel you can use application DumpChan
Related
To ensure that a method got executed just once with given parameters (and only with those parameters), I think I have to check it twice so like:
_fileHandlerMock.Verify(x => x.DeleteFile("file.txt"), Times.Once);
_fileHandlerMock.Verify(x => x.DeleteFile(It.IsAny<string>()), Times.Once);
Is there a better way to check, something like an "exclusive" option or so?
Moq library provides the method specifically for that purpose. It is VerifyNoOtherCalls, it is used in combination with the verifying and it will ensure that no other calls have been made except the (already) verified calls.
_fileHandlerMock.Verify(x => x.DeleteFile("file.txt"), Times.Once);
_fileHandlerMock.VerifyNoOtherCalls();
I want to hang the call just after answered.
exten => _3XXXXXXXXXX,1,Set(CALLERID(num)=1234567890)
same => n,MixMonitor(${UNIQUEID}.wav)
same => n,Dial(SIP/${EXTEN:1}#provider,,M(hang))
same => n,StopMixMonitor()
same => n,Hangup()
[macro-hang]
exten => s,1,Hangup()
any idea? I've tried a macro, but its not working.
From asterisk doc
M(macro[^arg[^...]]):
macro - Name of the macro that should be executed.
arg - Macro arguments
Execute the specified <macro> for the *called* channel before connecting to the
calling channel. Arguments can be specified to the Macro using '^' as a
delimiter. The macro can set the variable ${MACRO_RESULT} to specify the
following actions after the macro is finished executing:
${MACRO_RESULT}: If set, this action will be taken after the macro
finished executing.
ABORT: Hangup both legs of the call
CONGESTION: Behave as if line congestion was encountered
BUSY: Behave as if a busy signal was encountered
CONTINUE: Hangup the called party and allow the calling party to
continue dialplan execution at the next priority
GOTO:[[<context>^]<exten>^]<priority>: Transfer the call to the
specified destination.
Both ABORT and CONTINUE should do what you want.
Use Dial's L option. This way you can adjust the length of the call. From https://www.voip-info.org/asterisk-cmd-dial :
L(x[:y][:z]): Limit the call to ‘x’ ms, warning when ‘y’ ms are left, repeated every ‘z’ ms).
Note: If you will make the calls to a SIP provider, they will round up the up time (if you set L(1), even if it is 1 ms it will count as 1 second). Also, they will most likely suspend your account for wangiri fraud.
I use ARI to call 2 endpoints and Bridget them.
I want to hold or play media or play MOH call1 until endpoint2 answer call and then Bridget them.
I tried this plan but PlayBack, BackGround, MusicOnHold all of them block the thread until playing is finished and then call endpoint2.
exten => 107,1,NoOp()
same => n,Answer()
same => n,MusicOnHold(default,10)
#same => n,BackGround(silence/2&hello-world)
same => n,Dial(Local/***#from_internal_testing,U(default^postAnswer^1)) same => n,Hangup()
Are you really using ARI (i.e. Asterisk REST API)? I do not see that you are calling Stasis application from the dialplan. However, this operation should be invoked before you hand over the control over your channel to ARI.
All the methods mentioned above are suppored by ARI in the context “Channels”. The related specification is available here: https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Channels+REST+API
What you trying to do do not require anything like that, just use app_queue
https://wiki.asterisk.org/wiki/display/AST/Building+Queues
If for some reason you still want do all that youself, you can use TIMEOUT(), dial via Local, conference etc.
I have a setup for :
_fusionPORepMock.Setup(s => s.GetByFusionVersionID(It.Is<int>(i => i.Equals(123)))).Returns(_currentPO);
_fusionPORepMock.Setup(s => s.GetByFusionVersionID(It.Is<int>(i => i.Equals(111)))).Returns(_previousPO);
However Moq overrides the value for the first setup even if the arguments are different.
Any ideas or concrete solution for my problem?
I do not want to create another mock.
I'm not completely sure why using It.Is in this way clobbers the first setup, but if you just pass the raw integer you'll get the behavior you'll expect (and with less code):
_fusionPORepMock.Setup(s => s.GetByFusionVersionID(123)).Returns(_currentPO);
_fusionPORepMock.Setup(s => s.GetByFusionVersionID(111)).Returns(_previousPO);
I am writing a dialplan in Asterisk where I am required to implement a bookmarking feature. If a user calls in and the call gets disconnected, on redial the user must be taken to the exact same clip on which the call was dropped or disconnected last. The dialplan (with bookmarking feature) currently looks something like so:
[some-context]
exten => 0,n,System(progressmarker.sh ${CALLERID(num)} ${CONTEXT})
exten => 0,1,Background(wav1)
exten => 0,n,Background(wav2)
There are hundreds of such commands. progressmarker takes the context and puts it into a file. When the user wants to continue the old session, it starts from the last context the user was in. If the call gets dropped after wav1 or wav2, the user should start from wav1 or wav2 and not from the last context.
There is one way of doing this:
exten => 0,n(wav1),Background(wav1)&System(progressmarker.sh ${CALLERID(num)} ${CONTEXT} wav1)
But you can see this way is inelegant and cumbersome especially since there are hundreds of such commands. Is there a better way of implementing the bookmarking feature?
One way to do this is to employ the h extension. This is the extension that gets called when the channel encounters a hangup. The solution would look like so:
Keep saving the priority in a global variable.
Implement the hangup extension for each context. The channel variables such as last context, extension and priority are all accessible (contrary to what the documentation says). The extension will look something like so:
exten => h,1,System(<Execute a script here that saves the last context, extension and priority to a file that can be read later and control returned here.>)