-
Notifications
You must be signed in to change notification settings - Fork 119
/
sip.rb
46 lines (44 loc) · 2.26 KB
/
sip.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require "opentok/client"
# An object that lets you use the OpenTok SIP gateway.
module OpenTok
class Sip
# Dials a SIP gateway to input an audio-only stream into your OpenTok session.
# See the {https://tokbox.com/developer/guides/sip/ OpenTok SIP developer guide}.
#
# @example
# opts = { "from" => "14155550101@example.com",
# "auth" => { "username" => sip_username,
# "password" => sip_password },
# "headers" => { "X-KEY1" => "value1",
# "X-KEY1" => "value2" },
# "secure" => "true"
# }
# response = opentok.sip.dial(session_id, token, "sip:+15128675309@acme.pstn.example.com;transport=tls", opts)
# @param [String] session_id The session ID corresponding to the session to which
# the SIP gateway will connect.
# @param [String] token The token for the session ID with which the SIP user
# will use to connect.
# @param [String] sip_uri The SIP URI the OpenTok SIP gateway will dial.
# @param [Hash] opts A hash defining options for the SIP call. For example:
# @option opts [String] :from 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.
# @option opts [Hash] :headers This hash defines custom headers to be added
# to the SIP INVITE request initiated from OpenTok to the your SIP platform.
# @option opts [Hash] :auth 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.
# @option opts [true, false] :secure Wether the media must be transmitted
# encrypted (true) or not (false, the default).
def dial(session_id, token, sip_uri, opts)
response = @client.dial(session_id, token, sip_uri, opts)
end
def initialize(client)
@client = client
end
end
end