@@ -60,6 +60,15 @@ def __init__(self, api_key, api_secret, api_url='https://api.opentok.com'):
6060 self .api_key = str (api_key )
6161 self .api_secret = api_secret
6262 self .api_url = api_url
63+ self ._proxies = None
64+
65+ @property
66+ def proxies (self ):
67+ return self ._proxies
68+
69+ @proxies .setter
70+ def proxies (self , proxies ):
71+ self ._proxies = proxies
6372
6473 def generate_token (self , session_id , role = Roles .publisher , expire_time = None , data = None ):
6574 """
@@ -180,12 +189,12 @@ def create_session(self, location=None, media_mode=MediaModes.relayed, archive_m
180189 :param String media_mode: Determines whether the session will transmit streams using the
181190 OpenTok Media Router (MediaMode.routed) or not (MediaMode.relayed). By default,
182191 the setting is MediaMode.relayed.
183-
192+
184193 With the media_mode property set to MediaMode.relayed, the session
185- 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
186195 due to firewall restrictions, the session uses the OpenTok TURN server to relay
187196 audio-video streams.
188-
197+
189198 The `OpenTok Media
190199 Router <https://tokbox.com/opentok/tutorials/create-session/#media-mode>`_
191200 provides the following benefits:
@@ -237,7 +246,7 @@ def create_session(self, location=None, media_mode=MediaModes.relayed, archive_m
237246 options [u ('location' )] = location
238247
239248 try :
240- response = requests .post (self .session_url (), data = options , headers = self .headers ())
249+ response = requests .post (self .session_url (), data = options , headers = self .headers (), proxies = self . proxies )
241250 response .encoding = 'utf-8'
242251
243252 if response .status_code == 403 :
@@ -325,7 +334,7 @@ def start_archive(self, session_id, has_audio=True, has_video=True, name=None, o
325334 'outputMode' : output_mode .value
326335 }
327336
328- response = requests .post (self .archive_url (), data = json .dumps (payload ), headers = self .archive_headers ())
337+ response = requests .post (self .archive_url (), data = json .dumps (payload ), headers = self .archive_headers (), proxies = self . proxies )
329338
330339 if response .status_code < 300 :
331340 return Archive (self , response .json ())
@@ -351,7 +360,7 @@ def stop_archive(self, archive_id):
351360
352361 :rtype: The Archive object corresponding to the archive being stopped.
353362 """
354- response = requests .post (self .archive_url (archive_id ) + '/stop' , headers = self .archive_headers ())
363+ response = requests .post (self .archive_url (archive_id ) + '/stop' , headers = self .archive_headers (), proxies = self . proxies )
355364
356365 if response .status_code < 300 :
357366 return Archive (self , response .json ())
@@ -374,7 +383,7 @@ def delete_archive(self, archive_id):
374383
375384 :param String archive_id: The archive ID of the archive to be deleted.
376385 """
377- response = requests .delete (self .archive_url (archive_id ), headers = self .archive_headers ())
386+ response = requests .delete (self .archive_url (archive_id ), headers = self .archive_headers (), proxies = self . proxies )
378387
379388 if response .status_code < 300 :
380389 pass
@@ -392,7 +401,7 @@ def get_archive(self, archive_id):
392401
393402 :rtype: The Archive object.
394403 """
395- response = requests .get (self .archive_url (archive_id ), headers = self .archive_headers ())
404+ response = requests .get (self .archive_url (archive_id ), headers = self .archive_headers (), proxies = self . proxies )
396405
397406 if response .status_code < 300 :
398407 return Archive (self , response .json ())
@@ -421,7 +430,7 @@ def get_archives(self, offset=None, count=None):
421430 if count is not None :
422431 params ['count' ] = count
423432
424- response = requests .get (self .archive_url () + "?" + urlencode (params ), headers = self .archive_headers ())
433+ response = requests .get (self .archive_url () + "?" + urlencode (params ), headers = self .archive_headers (), proxies = self . proxies )
425434
426435 if response .status_code < 300 :
427436 return ArchiveList (self , response .json ())
0 commit comments