Suggestions

close search

Add Messaging, Voice, and Authentication to your apps with Vonage Communications APIs

Visit the Vonage API Developer Portal

Class: OpenTok::Sip

Inherits:
Object
Defined in:
lib/opentok/sip.rb

Instance Method Summary

Constructor Details

#initialize(client) ⇒ Sip

Returns a new instance of Sip.

Instance Method Details

#dial(session_id, token, sip_uri, opts) ⇒ Object

Dials a SIP gateway to input an audio-only stream into your OpenTok session. See the / OpenTok SIP developer guide.

Examples:

<span class="id identifier rubyid_opts">opts</span> <span class="op">=</span> <span class="lbrace">{</span> <span class="tstring"><span class="tstring_beg">"</span><span class="tstring_content">from</span><span class="tstring_end">"</span></span> <span class="op">=></span> <span class="tstring"><span class="tstring_beg">"</span><span class="tstring_content">14155550101@example.com</span><span class="tstring_end">"</span></span><span class="comma">,</span>
  <span class="tstring"><span class="tstring_beg">"</span><span class="tstring_content">auth</span><span class="tstring_end">"</span></span> <span class="op">=></span> <span class="lbrace">{</span> <span class="tstring"><span class="tstring_beg">"</span><span class="tstring_content">username</span><span class="tstring_end">"</span></span> <span class="op">=></span> <span class="id identifier rubyid_sip_username">sip_username</span><span class="comma">,</span>
    <span class="tstring"><span class="tstring_beg">"</span><span class="tstring_content">password</span><span class="tstring_end">"</span></span> <span class="op">=></span> <span class="id identifier rubyid_sip_password">sip_password</span> <span class="rbrace">}</span><span class="comma">,</span>
  <span class="tstring"><span class="tstring_beg">"</span><span class="tstring_content">headers</span><span class="tstring_end">"</span></span> <span class="op">=></span> <span class="lbrace">{</span> <span class="tstring"><span class="tstring_beg">"</span><span class="tstring_content">X-KEY1</span><span class="tstring_end">"</span></span> <span class="op">=></span> <span class="tstring"><span class="tstring_beg">"</span><span class="tstring_content">value1</span><span class="tstring_end">"</span></span><span class="comma">,</span>
    <span class="tstring"><span class="tstring_beg">"</span><span class="tstring_content">X-KEY1</span><span class="tstring_end">"</span></span> <span class="op">=></span> <span class="tstring"><span class="tstring_beg">"</span><span class="tstring_content">value2</span><span class="tstring_end">"</span></span> <span class="rbrace">}</span><span class="comma">,</span>
  <span class="tstring"><span class="tstring_beg">"</span><span class="tstring_content">secure</span><span class="tstring_end">"</span></span> <span class="op">=></span> <span class="tstring"><span class="tstring_beg">"</span><span class="tstring_content">true</span><span class="tstring_end">"</span></span>
<span class="rbrace">}</span>
<span class="id identifier rubyid_response">response</span> <span class="op">=</span> <span class="id identifier rubyid_opentok">opentok</span><span class="period">.</span><span class="id identifier rubyid_sip">sip</span><span class="period">.</span><span class="id identifier rubyid_dial">dial</span><span class="lparen">(</span><span class="id identifier rubyid_session_id">session_id</span><span class="comma">,</span> <span class="id identifier rubyid_token">token</span><span class="comma">,</span> <span class="tstring"><span class="tstring_beg">"</span><span class="tstring_content">sip:+15128675309@acme.pstn.example.com;transport=tls</span><span class="tstring_end">"</span></span><span class="comma">,</span> <span class="id identifier rubyid_opts">opts</span><span class="rparen">)</span>

Parameters:

  • session_id (String)

    The session ID corresponding to the session to which the SIP gateway will connect.

  • token (String)

    The token for the session ID with which the SIP user will use to connect.

  • sip_uri (String)

    The SIP URI the OpenTok SIP gateway will dial.

  • opts (Hash)

    A hash defining options for the SIP call. For example:

Options Hash (opts):

  • :from (String)

    The number or string that will be sent to the final SIP number as the caller. It must be a string in the form of “from@example.com”, where from can be a string or a number. If from is set to a number (for example, “14155550101@example.com”), it will show up as the incoming number on PSTN phones. If from is undefined or set to a string (for example, “joe@example.com”), +00000000 will show up as the incoming number on PSTN phones.

  • :headers (Hash)

    This hash defines custom headers to be added to the SIP ​INVITE​ request initiated from OpenTok to your SIP platform.

  • :auth (Hash)

    This object contains the username and password to be used in the the SIP INVITE​ request for HTTP digest authentication, if it is required by your SIP platform.

  • :secure (true, false)

    Wether the media must be transmitted encrypted (​true​) or not (​false​, the default).