|
Development
|
Written by Gurito
|
|
A few days ago I was asked to implement a ring group in Asterisk. I thought okay, it's pretty straight forward, I just put all the devices I want to ring in a Dial command and that's it. So I did, but then I was told that that was not entirely ok. They wanted a delay between devices, such that at first only one phone would ring, X seconds later a second device (without the first one stopping) and so on. I thought I could put more Dial commands in a specific order, but then I had the problem that if the first one didn't answer, it would indicate a missed call. So here is how I finally solved it with help of my colleague Bleek. [wait-op] ; Ask if the channel is available, if it is ; go to the next step. If it isn't go to no-op ; and skip the delay. exten = _XX,1,ChanIsAvail(SIP/${EXTEN}) exten = _XX,n,GotoIf($[ "${AVAILCHAN}"="" ]?no-op|s-na|1:3) ; Increment the delay by a value of five. exten = _XX,n,Set(DB(cross/delay-${key})=$[${DB(cross/delay-${key})}+5]) exten = _XX,n,Wait(${DB(cross/delay-${key})}) exten = _XX,n,Dial(SIP/${EXTEN}) [no-op] ; Do nothing exten = s,1,NoOp(Dummy) exten = s-na,1,NoOp(Channel is not available) [hotline-0] ; Define a custom name for the caller ID. ; This was an extra that I did exten = s,1,Set(CALLERID(name)=hotline ${CALLERID(name)} ${CALLERID(num)}) ; Set a key unique for each channel. So id doesn't matter how ; many calls we get, there will always exist just one key per channel ; This way we increase the delay only when we want to. exten = s,n,Set(__key=${CHANNEL}) ; Define the initial delay value on the database. That's even better than ; a global variable. One advantage, pointed out by a collegue of mine, is ; that when the process is over, you can delete the key from the DB. exten = s,n,Set(DB(cross/delay-${key})=-5) ; Set all the devices as a single variable. ; Note that all of them use the "Local" context exten = s,n,Set(dg0=Local/91@wait-op) exten = s,n,Set(dg0=${dg0}&Local/93@wait-op) exten = s,n,Set(dg0=${dg0}&Local/95@wait-op) exten = s,n,Set(dg0=${dg0}&Local/20@wait-op) exten = s,n,Set(dg0=${dg0}&Local/21@wait-op) exten = s,n,Set(dg0=${dg0}&Local/50@wait-op) exten = s,n,Set(dg0=${dg0}&Local/22@wait-op) exten = s,n,Dial(${dg0}|80) ; Manage the voicemail with a macro exten = s,n,Macro(hotline-voicemail|${DIALSTATUS}|0) ; Delete the keys at hangup exten = h,1,NoOp(DB_DELETE(cross/inc-${key}) exten = h,n,Hangup [macro-hotline-voicemail] ; ${ARG1} Dialstatus ; ${ARG2} Whose voicemail? exten = s,1,Set(CHANNEL(language)=de) exten = s,n,Goto(s-${ARG1},1) exten = s-BUSY,1,Voicemail(${ARG2},b) exten = s-NOANSWER,1,Voicemail(${ARG2},u) exten = s-CONGESTION,1,Voicemail(${ARG2},b) exten = s-CHANUNAVAIL,1,Voicemail(${ARG2},u)
I know it's perhaps not the best approach. We didn't want to use queues, because our peers aren't agents, and, though it can be optimised, it works now :) Hope it helps somebody, Happy coding. |
|
Last Updated on Tuesday, 31 March 2009 14:55 |
|
|
Written by Gurito
|
|
So, I did a fresh install from Asterisk on a server, then configured some SIP users and connected Snom phones for each one of them. Then, as I was testing, I noticed that the "Mail" button on the Snom phones dialed an extension "asterisk". So I couldn't get around dialing the general voicemail extension in order to check my mail. Anyway, there are a few solutions to this problem. One of them is including the option "vmexten" for each user, either in sip.conf or in users.conf. The problem with this approach is that any other user can dial any existing "vmexten" value and, given that he/she knows the password for this voicemail, access the mailbox. So, in order to solve this problem a collegue told me that it was perhaps a good idea to use the "asterisk" extension. Here is how I did it. In the file "extensions.conf" I performed the next changes: ; ; *First thing is defining an ew context for the voicemail* [voicemail] exten = asterisk,1,NoOp(This extension takes us to check the voicemail) exten = asterisk,n,NoOp(Caller ID : ${CALLERID(num)}) exten = asterisk,n,NoOp(Channel Type : ${CHANNEL(channeltype)}) exten = asterisk,n,GotoIf($[ "${CHANNEL(channeltype)}" = "SIP" ]?asterisk-sip,1) exten = asterisk,n,GotoIf($[ "${CHANNEL(channeltype)}" = "IAX2" ]?asterisk-iax,1) exten = asterisk-sip,1,NoOp(SIP Name : ${SIPCHANINFO(peername)}) exten = asterisk-sip,n,NoOp(Mailbox : ${SIPPEER(${SIPCHANINFO(peername)}|mailbox)}) exten = asterisk-sip,n,Macro(voicemail-general|${SIPPEER(${SIPCHANINFO(peername)}|mailbox)}) ; *Now, there's no IAXCHANINFO on asterisk 1.2 - 1.4. But it will work if you have an IAX2 client* ; *that supports entering voicemail login info. (like voix phone)* exten = asterisk-iax,1,NoOp(IAX automatic voicemail is not yet supported) exten = asterisk-iax,n,Macro(voicemail-general) ; *Second thing is definig a Voicemail Macro.* ; *Think of this macro as of a function which performs a login for the voicemail.* [macro-voicemail-general] ; ${ARG1} = User's mailbox ; *If the SIP 12 has the mailbox 30, then ${ARG1} = 30.* ; *But don't worry, this parameter is already given by the "asterisk" context previously defined.* ; Set the language for the voicemail message. exten = s,1,Set(CHANNEL(language)=de) exten = s,n,Answer() exten = s,n,GotoIf($[ ${ISNULL(${ARG1})} ]?s-null,1) ; *In my case I had to put this wait in order for the greeting message to play completely.* exten = s,n,Wait(1) exten = s,n,VoiceMailMain(${ARG1}) exten = s,n,Hangup() ; *The extension s-null is called when ${ARG1} is empty* ; *In this case, we call VoiceMailMain withouth parameters and, if the client, say voix phone,* ; *has the voicemail login data configured, it will pass it automatically to asterisk.* ; *It may well be that you don't need the "Wait()" here* exten = s-null,1,Wait(1) exten = s-null,n,VoiceMailMain() exten = s-null,n,Hangup() ; *Finally, I included the "voicemail" context on the default context for my users.* [default] include = voicemail ...
So that's it... I hope you find it useful.
Happy coding. :) |
|
Last Updated on Tuesday, 31 March 2009 15:03 |
|
Written by Gurito
|
|
Recently I'm involved in a project in which we have the following (simplest) scenario. Two machines are using RMI in a network. We want to use RMI over SSL in order to make it secure. And we want to be able to read certificates in both sides, server and client. In both sides we want to check the contents of the certificates before actually establishing a connection. For this purpose I wrote a very basic implementation of ServerSocket. In this class I delegate the methods to SSLServerSocket and CryptoBroker is a class which provides a Context, with which we construct an SSLServerSocket. You should write your own methods to do this. |
|
Last Updated on Tuesday, 31 March 2009 15:07 |
|
Read more...
|
|
Written by Gurito
|
|
Well, I really don't know why the guys from Jpackage don't provide an rpm for sun java 64 bit. And, well, I did want to use it. So I just made myself a java-sun-compat which works with the latest version of java (1.6_u2). I'm using it currently in Fedora 7 (I guess it works for more distros though), and it should be safe --as I built it from the Source rpm from Jpackage. So, actually, the credit is not mine, I just rebuilt it. :p Anyway, as always, you're free to download it from the downloads section. :) |
|
Written by Gurito
|
|
This was a program we had to implement at the university a couple of months ago... It's just a tiny piece of code showing how to perform the sum of the squared numbers in [0, N]. That means, 1^2 + 2^2 + ... + N^2. It's written in c and, well.. you'll find it pretty straight forward. |
|
Last Updated on Tuesday, 31 March 2009 15:13 |
|
Read more...
|
|
|
|
|
|
|
Page 1 of 2 |
|