| CCXML 1.0-W3C Development Guide | Home | Frameset Home |
|
<ccxml> element containers, (remembering to specify the voxeo XML namespace, so that we can make use of the nifty extension elements!):
<?xml version="1.0" encoding="UTF-8"?>
<!-- NOTE THAT WE *MUST* DECLARE THE xmlns ATTRIBUTE -->
<ccxml version="1.0" xmlns:voxeo="http://community.voxeo.com/xmlns/ccxml">
</ccxml>
<accept> the call:
<?xml version="1.0" encoding="UTF-8"?>
<!-- NOTE THAT WE *MUST* DECLARE THE xmlns ATTRIBUTE -->
<ccxml version="1.0" xmlns:voxeo="http://community.voxeo.com/xmlns/ccxml">
<eventprocessor>
<transition event="connection.alerting">
<log expr="'*** connection.alerting ***'"/>
<accept/>
<log expr="'*** call accepted ***'"/>
</transition>
</eventprocessor>
</ccxml>
<accept> a call that has already been accepted while in the "connection.alerting" phase? Huh? You don't know either? Well, let's find out:
<?xml version="1.0" encoding="UTF-8"?>
<!-- NOTE THAT WE *MUST* DECLARE THE xmlns ATTRIBUTE -->
<ccxml version="1.0" xmlns:voxeo="http://community.voxeo.com/xmlns/ccxml">
<eventprocessor>
<transition event="connection.alerting">
<log expr="'*** connection.alerting ***'"/>
<accept/>
<log expr="'*** call accepted ***'"/>
</transition>
<transition event="connection.connected">
<log expr="'*** connection.connected ***'"/>
<!-- hey, we cant accept a call twice! -->
<accept/>
</transition>
</eventprocessor>
</ccxml>
<transition> events:<transition event="error*"><transition event="error.connection.*"><transition event="error.connection.wrongstate"><transition> as accurately, and as specific as possible. In addition, we can access all kinds of nifty information by accessing the fields of this event, (which is why we are specifying a "name" attribute for this <transition>. There are different fields defined for just about every kind of asynchonous event that we can trap, and the "error.wrongstate" event has a plethora of data that we can access. So what's the process for getting at all this useful data? It's pretty easy actually: All we do is add a variable assignment, or a <log> statement that references the following syntax:
[transition name].[field name]
<?xml version="1.0" encoding="UTF-8"?>
<!-- NOTE THAT WE *MUST* DECLARE THE xmlns ATTRIBUTE -->
<ccxml version="1.0" xmlns:voxeo="http://community.voxeo.com/xmlns/ccxml">
<eventprocessor>
<transition event="connection.alerting">
<log expr="'*** connection.alerting ***'"/>
<accept/>
<log expr="'*** call accepted ***'"/>
</transition>
<transition event="connection.connected">
<log expr="'*** connection.connected ***'"/>
<!-- hey, we cant accept a call twice! -->
<accept/>
</transition>
<transition event="error.connection.wrongstate">
<log expr="'*** event$.name = ' + event$.name"/>
<log expr="'*** event$.connectionid = ' + event$.connectionid"/>
<log expr="'*** event$.protocol = ' + event$.protocol"/>
<log expr="'*** event$.reason = ' + event$.reason"/>
<log expr="'*** event$.info = ' + event$.info"/>
<log expr="'*** event$.connection = ' + event$.connection"/>
<log expr="'*** event$.tagname = ' + event$.tagname"/>
<log expr="'*** event$.eventid = ' + event$.eventid"/>
<log expr="'*** event$.eventsource = ' + event$.eventsource"/>
<log expr="'*** event$.eventsourcetype = ' + event$.eventsourcetype"/>
<log expr="'*** event$.tagname = ' + event$.tagname"/>
<exit/>
</transition>
</eventprocessor>
</ccxml>
<transition>, folks. So what sort of data do we get from these fields? Let's take a peek at our log output when we place a call into the application:
log: *** event$.name = error.connection.wrongstate
log: *** event$.connectionid = 029e5f07ac0bc796a493d9f892d0b2ae
log: *** event$.protocol = sip
log: *** event$.reason = accept can only be executed in CONNSTATE_ALERTING
log: *** event$.info = undefined
log: *** event$.connection = [object Connection]
log: *** event$.tagname = accept
log: *** event$.eventid = f3c0e45d8c43c48b758561bfc4684416
log: *** event$.eventsource = 029e5f07ac0bc796a493d9f892d0b2ae
log: *** event$.eventsourcetype = ccxml
log: *** event$.tagname = accept
<exit> the application after handling a fatal event. Otherwise, we could see that our CCXML session doesn't get shut down properly. Note: This is not good.<transition> handler for the possible error types, and log some event fields to give us some diagnostic data, and then <exit> to prevent the possibility of a call not getting shut down properly. But what happens if we get an error within our error handler, smart guy?
<?xml version="1.0" encoding="UTF-8"?>
<!-- NOTE THAT WE *MUST* DECLARE THE xmlns ATTRIBUTE -->
<ccxml version="1.0" xmlns:voxeo="http://community.voxeo.com/xmlns/ccxml">
<eventprocessor>
<transition event="connection.alerting">
<log expr="'*** connection.alerting ***'"/>
<accept/>
<log expr="'*** call accepted ***'"/>
</transition>
<transition event="connection.connected">
<log expr="'*** connection.connected ***'"/>
<accept/>
</transition>
<transition event="error.connection.wrongstate">
<log expr="'*** event$.name = ' + event$.name"/>
<log expr="'*** event$.connectionid = ' + event$.connectionid"/>
<log expr="'*** event$.protocol = ' + event$.protocol"/>
<log expr="'*** event$.reason = ' + event$.reason"/>
<log expr="'*** event$.info = ' + event$.info"/>
<log expr="'*** event$.connection = ' + event$.connection"/>
<log expr="'*** event$.tagname = ' + event$.tagname"/>
<log expr="'*** event$.eventid = ' + event$.eventid"/>
<log expr="'*** event$.eventsource = ' + event$.eventsource"/>
<log expr="'*** event$.eventsourcetype = ' + event$.eventsourcetype"/>
<log expr="'*** event$.tagname = ' + event$.tagname"/>
<log expr="'** bogus object = ' + celebrities.that.keep.political.opinions.to.themselves"/>
<exit/>
</transition>
<transition event="error.*">
<log expr="'an error has occured (' + event$.name + ')'"/>
<log expr="'*** ' + event$.name + ' detected ***'"/>
<log expr="'*** event$.name = ' + event$.name"/>
<log expr="'*** event$.reason = ' + event$.reason"/>
<log expr="'*** event$.tagname = ' + event$.tagname"/>
<log expr="'*** event$.eventid = ' + event$.eventid"/>
<log expr="'*** event$.eventsource = ' + event$.eventsource"/>
<log expr="'*** event$.eventsourcetype = ' + event$.eventsourcetype"/>
<voxeo:sendemail to="'youremailaddress@somewhere.com'"
from="'myApp@voxeo.com'"
type="'debug'"
body="'An unexpected error has occurred \n Time to panic! \n
Flee the cities, abandon all hope!'"/>
<exit/>
</transition>
</eventprocessor>
</ccxml>
<transition> for our "wrongstate" handler. Since this object is undeclared, the CCXML interpreter won't know what this is, and will throw a fatal "error.semantic". You'll also note that we have added the "wildcard" event handler for the "error" wildcard string. Since we don't have an explicit handler for <transition event="error.semantic">, this event will be caught by our wildcard handler. You'll note that again, we are logging all the available fields in this new handler via the <log> element because, well, more information is better when we have to debug something, right? Astute readers will see the return of the <exit> tag within this handler, too, because, (feel free to read this part aloud), we always exit our CCXML explicitly when we encounter an error. But we did sneak in another addition, (remember: we are sneaky): The <voxeo:sendemail> extension element. What the heck is this all about? As we understand that not everyone watches a debugger stream 24x7 except Voxeo employees, we realize that the developer might want a more proactive means of being notified when an application bombs out on us. Enter the <voxeo:sendemail> element, which will send us an email that alerts us to this fact. Of course, you'll probably want to edit this so that, you know, your own email address is specified in order for this to work, and as it is an extension element, we must reference the voxeo XML namespace in our initial <ccxml> declaration, as we stated in Step 1.<voxeo:sendemail> tag to provide proactive notifications when application errors do occur.| ANNOTATIONS: EXISTING POSTS |
| login |
|