Skip to content

Commit f28963d

Browse files
committed
changes default create_session to relayed, fixes #33
1 parent 5df402f commit f28963d

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

opentok/opentok.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def generate_token(self, session_id, role=Roles.publisher, expire_time=None, dat
149149
)
150150
return token
151151

152-
def create_session(self, location=None, media_mode=MediaModes.routed):
152+
def create_session(self, location=None, media_mode=MediaModes.relayed):
153153
"""
154154
Creates a new OpenTok session and returns the session ID, which uniquely identifies
155155
the session.
@@ -172,10 +172,10 @@ def create_session(self, location=None, media_mode=MediaModes.routed):
172172
:param String mediaMode: Determines whether the session will transmit streams using the
173173
OpenTok Media Router (MediaMode.ROUTED) or not (MediaMode.RELAYED). By default,
174174
sessions use the OpenTok Media Router.
175-
175+
176176
The OpenTok Media Router (see http://www.tokbox.com/#multiparty)
177177
provides the following benefits:
178-
178+
179179
* The OpenTok Media Router can decrease bandwidth usage in multiparty sessions.
180180
(When the mediaMode property is set to MediaMode.RELAYED, each client must send
181181
a separate audio-video stream to each client subscribing to it.)
@@ -189,12 +189,12 @@ def create_session(self, location=None, media_mode=MediaModes.routed):
189189
190190
* The OpenTok Media Router supports the archiving feature, which lets
191191
you record, save, and retrieve OpenTok sessions (see http://tokbox.com/platform/archiving).
192-
192+
193193
With the mediaMode property set to MediaMode.RELAYED, the session
194-
will attempt to transmit streams directly between clients. If clients cannot connect
194+
will attempt to transmit streams directly between clients. If clients cannot connect
195195
due to firewall restrictions, the session uses the OpenTok TURN server to relay
196196
audio-video streams.
197-
197+
198198
You will be billed for streamed minutes if you use the OpenTok Media Router or if the
199199
session uses the OpenTok TURN server to relay streams. For information on pricing, see
200200
the OpenTok pricing page (http://www.tokbox.com/pricing).

tests/test_session_creation.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,27 @@ def test_create_default_session(self):
2424

2525
expect(httpretty.last_request().headers[u('x-tb-partner-auth')]).to.equal(self.api_key+u(':')+self.api_secret)
2626
expect(httpretty.last_request().headers[u('user-agent')]).to.contain(u('OpenTok-Python-SDK/')+__version__)
27-
expect(httpretty.last_request().body).to.equal(b('p2p.preference=disabled'))
27+
expect(httpretty.last_request().body).to.equal(b('p2p.preference=enabled'))
2828
expect(session).to.be.a(Session)
2929
expect(session).to.have.property(u('session_id')).being.equal(u('1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg'))
30-
expect(session).to.have.property(u('media_mode')).being.equal(MediaModes.routed)
30+
expect(session).to.have.property(u('media_mode')).being.equal(MediaModes.relayed)
3131
expect(session).to.have.property(u('location')).being.equal(None)
3232

3333
@httpretty.activate
34-
def test_create_p2p_session(self):
34+
def test_create_routed_session(self):
3535
httpretty.register_uri(httpretty.POST, u('https://api.opentok.com/session/create'),
3636
body=u('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><sessions><Session><session_id>1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg</session_id><partner_id>123456</partner_id><create_dt>Mon Mar 17 00:41:31 PDT 2014</create_dt></Session></sessions>'),
3737
status=200,
3838
content_type=u('text/xml'))
3939

40-
session = self.opentok.create_session(media_mode=MediaModes.relayed)
40+
session = self.opentok.create_session(media_mode=MediaModes.routed)
4141

4242
expect(httpretty.last_request().headers[u('x-tb-partner-auth')]).to.equal(self.api_key+u(':')+self.api_secret)
4343
expect(httpretty.last_request().headers[u('user-agent')]).to.contain(u('OpenTok-Python-SDK/')+__version__)
44-
expect(httpretty.last_request().body).to.equal(b('p2p.preference=enabled'))
44+
expect(httpretty.last_request().body).to.equal(b('p2p.preference=disabled'))
4545
expect(session).to.be.a(Session)
4646
expect(session).to.have.property(u('session_id')).being.equal(u('1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg'))
47-
expect(session).to.have.property(u('media_mode')).being.equal(MediaModes.relayed)
47+
expect(session).to.have.property(u('media_mode')).being.equal(MediaModes.routed)
4848
expect(session).to.have.property(u('location')).being.equal(None)
4949

5050
@httpretty.activate
@@ -61,30 +61,30 @@ def test_create_session_with_location_hint(self):
6161
# ordering of keys is non-deterministic, must parse the body to see if it is correct
6262
body = parse_qs(httpretty.last_request().body)
6363
expect(body).to.have.key(b('location')).being.equal([b('12.34.56.78')])
64-
expect(body).to.have.key(b('p2p.preference')).being.equal([b('disabled')])
64+
expect(body).to.have.key(b('p2p.preference')).being.equal([b('enabled')])
6565
expect(session).to.be.a(Session)
6666
expect(session).to.have.property(u('session_id')).being.equal(u('1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg'))
67-
expect(session).to.have.property(u('media_mode')).being.equal(MediaModes.routed)
67+
expect(session).to.have.property(u('media_mode')).being.equal(MediaModes.relayed)
6868
expect(session).to.have.property(u('location')).being.equal(u('12.34.56.78'))
6969

7070
@httpretty.activate
71-
def test_create_p2p_session_with_location_hint(self):
71+
def test_create_routed_session_with_location_hint(self):
7272
httpretty.register_uri(httpretty.POST, u('https://api.opentok.com/session/create'),
7373
body=u('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><sessions><Session><session_id>1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg</session_id><partner_id>123456</partner_id><create_dt>Mon Mar 17 00:41:31 PDT 2014</create_dt></Session></sessions>'),
7474
status=200,
7575
content_type=u('text/xml'))
7676

77-
session = self.opentok.create_session(location='12.34.56.78', media_mode=MediaModes.relayed)
77+
session = self.opentok.create_session(location='12.34.56.78', media_mode=MediaModes.routed)
7878

7979
expect(httpretty.last_request().headers[u('x-tb-partner-auth')]).to.equal(self.api_key+u(':')+self.api_secret)
8080
expect(httpretty.last_request().headers[u('user-agent')]).to.contain(u('OpenTok-Python-SDK/')+__version__)
8181
# ordering of keys is non-deterministic, must parse the body to see if it is correct
8282
body = parse_qs(httpretty.last_request().body)
8383
expect(body).to.have.key(b('location')).being.equal([b('12.34.56.78')])
84-
expect(body).to.have.key(b('p2p.preference')).being.equal([b('enabled')])
84+
expect(body).to.have.key(b('p2p.preference')).being.equal([b('disabled')])
8585
expect(session).to.be.a(Session)
8686
expect(session).to.have.property(u('session_id')).being.equal(u('1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg'))
87-
expect(session).to.have.property(u('media_mode')).being.equal(MediaModes.relayed)
87+
expect(session).to.have.property(u('media_mode')).being.equal(MediaModes.routed)
8888
expect(session).to.have.property(u('location')).being.equal(u('12.34.56.78'))
8989

9090
# TODO: all the cases that throw exceptions

0 commit comments

Comments
 (0)