Skip to content

Commit bf7849e

Browse files
committed
renaming webhook -> websocket
1 parent a460134 commit bf7849e

File tree

5 files changed

+24
-35
lines changed

5 files changed

+24
-35
lines changed

README.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,15 @@ For more information about OpenTok live streaming broadcasts, see the
551551
`Broadcast developer guide <https://tokbox.com/developer/guides/broadcast/>`_.
552552

553553

554+
Streaming audio to a websocket
555+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
556+
You can stream audio to a websocket with the ``opentok.stream_audio_to_websocket`` method.
557+
558+
.. code:: python
559+
560+
websocket_options = {"uri": "wss://service.com/ws-endpoint"}
561+
websocketopentok.stream_audio_to_websocket(session_id, opentok_token, websocket_options)
562+
554563
Configuring Timeout
555564
-------------------
556565
Timeout is passed in the Client constructor:

opentok/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
from .sip_call import SipCall
1616
from .broadcast import Broadcast, BroadcastStreamModes
1717
from .render import Render, RenderList
18-
from .webhook_audio_connection import WebhookAudioConnection
18+
from .websocket_audio_connection import WebsocketAudioConnection

opentok/opentok.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from .streamlist import StreamList
3333
from .sip_call import SipCall
3434
from .broadcast import Broadcast, BroadcastStreamModes
35-
from .webhook_audio_connection import WebhookAudioConnection
35+
from .websocket_audio_connection import WebsocketAudioConnection
3636
from .exceptions import (
3737
ArchiveStreamModeError,
3838
BroadcastHLSOptionsError,
@@ -1806,7 +1806,7 @@ def list_renders(self, offset=0, count=50):
18061806

18071807
def stream_audio_to_websocket(self, session_id: str, opentok_token: str, websocket_options: dict):
18081808
"""
1809-
Connects audio streams to a specified webhook URI.
1809+
Connects audio streams to a specified websocket URI.
18101810
For more information, see the `Audio Streamer developer guide <https://tokbox.com/developer/guides/audio-streamer/>`.
18111811
18121812
:param String 'session_id': The OpenTok session ID that includes the OpenTok streams you want to include in the WebSocket stream. The Audio Streamer feature is only supported in routed sessions (sessions that use the OpenTok Media Router).
@@ -1841,7 +1841,7 @@ def stream_audio_to_websocket(self, session_id: str, opentok_token: str, websock
18411841
)
18421842

18431843
if response and response.status_code == 200:
1844-
return WebhookAudioConnection(response.json())
1844+
return WebsocketAudioConnection(response.json())
18451845
elif response.status_code == 400:
18461846
"""
18471847
The HTTP response has a 400 status code in the following cases:
@@ -1860,7 +1860,7 @@ def validate_websocket_options(self, options):
18601860
if type(options) is not dict:
18611861
raise InvalidWebsocketOptionsError('Must pass websocket options as a dictionary.')
18621862
if 'uri' not in options:
1863-
raise InvalidWebsocketOptionsError('Provide a webhook URI.')
1863+
raise InvalidWebsocketOptionsError('Provide a websocket URI.')
18641864

18651865
def _sign_string(self, string, secret):
18661866
return hmac.new(

opentok/webhook_audio_connection.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

tests/test_audio_streamer.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from six import u, PY2, PY3
88
from expects import *
9-
from opentok import Client, WebhookAudioConnection, __version__
9+
from opentok import Client, WebsocketAudioConnection, __version__
1010
from opentok.exceptions import InvalidWebsocketOptionsError, InvalidMediaModeError
1111
from .validate_jwt import validate_jwt_header
1212

@@ -43,7 +43,7 @@ def test_stream_audio_to_websocket(self):
4343
"uri": "wss://service.com/ws-endpoint"
4444
}
4545

46-
webhook_audio_connection = self.opentok.stream_audio_to_websocket(self.session_id, self.token, websocket_options)
46+
websocket_audio_connection = self.opentok.stream_audio_to_websocket(self.session_id, self.token, websocket_options)
4747

4848
validate_jwt_header(self, httpretty.last_request().headers[u("x-opentok-auth")])
4949
expect(httpretty.last_request().headers[u("user-agent")]).to(
@@ -60,11 +60,11 @@ def test_stream_audio_to_websocket(self):
6060
body = json.loads(httpretty.last_request().body.decode("utf-8"))
6161

6262
expect(body).to(have_key(u("token")))
63-
expect(webhook_audio_connection).to(be_a(WebhookAudioConnection))
64-
expect(webhook_audio_connection).to(
63+
expect(websocket_audio_connection).to(be_a(WebsocketAudioConnection))
64+
expect(websocket_audio_connection).to(
6565
have_property(u("id"), u("b0a5a8c7-dc38-459f-a48d-a7f2008da853"))
6666
)
67-
expect(webhook_audio_connection).to(
67+
expect(websocket_audio_connection).to(
6868
have_property(u("connectionId"), u("e9f8c166-6c67-440d-994a-04fb6dfed007"))
6969
)
7070

@@ -86,7 +86,7 @@ def test_stream_audio_to_websocket_custom_options(self):
8686
}
8787
}
8888

89-
webhook_audio_connection = self.opentok.stream_audio_to_websocket(self.session_id, self.token, websocket_options)
89+
websocket_audio_connection = self.opentok.stream_audio_to_websocket(self.session_id, self.token, websocket_options)
9090

9191
validate_jwt_header(self, httpretty.last_request().headers[u("x-opentok-auth")])
9292
expect(httpretty.last_request().headers[u("user-agent")]).to(
@@ -103,11 +103,11 @@ def test_stream_audio_to_websocket_custom_options(self):
103103
body = json.loads(httpretty.last_request().body.decode("utf-8"))
104104

105105
expect(body).to(have_key(u("token")))
106-
expect(webhook_audio_connection).to(be_a(WebhookAudioConnection))
107-
expect(webhook_audio_connection).to(
106+
expect(websocket_audio_connection).to(be_a(WebsocketAudioConnection))
107+
expect(websocket_audio_connection).to(
108108
have_property(u("id"), u("b0a5a8c7-dc38-459f-a48d-a7f2008da853"))
109109
)
110-
expect(webhook_audio_connection).to(
110+
expect(websocket_audio_connection).to(
111111
have_property(u("connectionId"), u("e9f8c166-6c67-440d-994a-04fb6dfed007"))
112112
)
113113

@@ -149,4 +149,4 @@ def test_stream_audio_to_websocket_missing_uri_error(self):
149149
websocket_options = {}
150150
with self.assertRaises(InvalidWebsocketOptionsError) as context:
151151
self.opentok.stream_audio_to_websocket(self.session_id, self.token, websocket_options)
152-
self.assertTrue("Provide a webhook URI." in str(context.exception))
152+
self.assertTrue("Provide a websocket URI." in str(context.exception))

0 commit comments

Comments
 (0)