O'Reilly Emerging Telephony

oreilly.comSafari Books Online.Conferences.
advertisement
MySQL Conference and Expo April 14-17, 2008, Santa Clara, CA
AddThis Social Bookmark Button

Listen Print Discuss Subscribe to Telephony Subscribe to Newsletters

OpenZoep: An Open Source VoIP Engine
Pages: 1, 2, 3

Jabber Streams

Now that you've mastered OpenZoep's basic methods, it's time to open the stream and make a phone call.



To open the stream, the following stanza should be sent:

  <?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
      <stream:stream to='jabber.voipster.com' xmlns='jabber:client'
      xmlns:stream='http://etherx.jabber.org/streams'>

There are two things to notice here. The first is the mandatory UTF-8 encoding, and the second is the host name of the Jabber server. Just replace jabber.voipster.com with your own Jabber server.

The following steps outline the lifecycle of a Jabber stream:

  1. Start a session by calling api_register_account().
  2. Set up the stream as described above.
  3. Inform the OpenZoep engine about your configuration settings by sending the configuration:iq stanza (see trac.web1.openzoep.org/main/wiki/MoipApiSubsystemPresence3 for details).
  4. Request the authorization method (see www.openzoep.org/docs/api/primer/311.htm).
  5. Log in (see www.openzoep.org/docs/api/primer/312.htm).
  6. Send a presence notification (see www.openzoep.org/docs/api/primer/314.htm).
  7. (Recurring) Send and receive messages during the lifetime of the application.
  8. Log out (see www.openzoep.org/docs/api/primer/313.htm).
  9. Close the stream (see www.openzoep.org/docs/api/primer/310.htm).
  10. Close the session by calling api_unregister_account().

The action happens in step 7. Here are some examples of stanzas (XML messages) you can send during step 7.

Making Phone Calls

The OpenZoep client-side engine can be instructed to establish a peer-to-peer phone call to Joe by sending this stanza:

   <voice id="phonecall_3cb5c86c-b40c-4e89-956b-f07d80650109"
      to="joe@jabber.voipster.com/Zoep" type="join">
      <call_id>show</call_id>
      <private>yes</private>
   </voice>

The id attribute of the voice element should contain a globally unique ID (most programming languages offer a library for generating a GUID). The to attribute contains the address of the Jabber contact you want to talk to. The call_id and private attributes are defined by XMPP but are not used by OpenZoep.

Making a call to a "normal" phone (land line or mobile) goes as follows:

   <voice id="phonecall_93a7ba89-4a99-45da-ac82-62f0ee6b4cad"
      to="unknown/#003110123456" type="join">
      <call_id>show</call_id>
      <private>yes</private>
   </voice>

Notice that the Jabber ID should be set to unknown and the number you wish to dial should be preceded by a hash sign (#) and a fully qualified international number. You also need to establish a call credit account with an OpenZoep PSTN provider in order to make phone calls to PSTN numbers (currently the only provider is zoep.com).

Answering Phone Calls

Answering an incoming call from Suzan is just as easy:

   <voice from='suzan@jabber.voipster.com/Zoep'
      id='phonecall_3cb5c86c-b40c-4e89-956b-f07d80650109'
      to='erik@jabber.voipster.com/Zoep' type='join'>
   </voice>

Send a message with the type attribute set to joined to accept the call. The to attribute specifies the Jabber ID of the callee:

   <voice id="phonecall_3cb5c86c-b40c-4e89-956b-f07d80650109"
      to="suzan@jabber.voipster.com/Zoep" type="joined"/>

After sending this message, you get the following response from Suzan:

   <voice from='suzan@jabber.voipster.com/Zoep'
      id='phonecall_3cb5c86c-b40c-4e89-956b-f07d80650109'
      to='erik@jabber.voipster.com/Zoep' type='joined'>
   </voice>

Suzan receives a similar message, only with the from and to attributes reversed:

   <voice from='erik@jabber.voipster.com/Zoep'
      id='phonecall_3cb5c86c-b40c-4e89-956b-f07d80650109'
      to='suzan@jabber.voipster.com/Zoep' type='joined'>
   </voice>

By the way, the join and joined terms originate from the fact that OpenZoep is fully prepared to handle multi-person conferences. Although technically not implemented yet, internally even two-person calls are handled as conferences.

Pages: 1, 2, 3

Next Pagearrow




Search Emerging Telephony

Search

Tagged Articles

Be the first to post this article to del.icio.us

Sponsored Resources

  • Inside Lightroom

Related to this Article

Take Control of Your iPhone Apps Take Control of Your iPhone Apps
by Jeff Carlson
November 2009
$10.00 USD

Take Control of iPhone OS 3 Take Control of iPhone OS 3
by Ted Landau
November 2009
$15.00 USD

Advertisement
O'Reilly Media

©2009, O'Reilly Media, Inc.
(707) 827-7000 / (800) 998-9938
All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.
About O'Reilly
Academic Solutions
Authors
Contacts
Customer Service
Jobs
Newsletters
O'Reilly Labs
Press Room
Privacy Policy
RSS Feeds
Terms of Service
User Groups
Writing for O'Reilly
Content Archive
Business Technology
Computer Technology
Google
Microsoft
Mobile
Network
Operating System
Digital Photography
Programming
Software
Web
Web Design
More O'Reilly Sites
O'Reilly Radar
Ignite
Tools of Change for Publishing
Digital Media
Inside iPhone
makezine.com
craftzine.com
hackszine.com
perl.com
xml.com

Partner Sites
InsideRIA
java.net
O'Reilly Insights on Forbes.com