Skip to content

Commit 6a3cbe3

Browse files
authored
Rtc 317 add secure option (#10)
* Add events to exports * test poetry * betterproto beta * non interactive docker * test deps * wip * Fix CI * add secure option * Add secure option * Fix lint * Fix
1 parent 201750f commit 6a3cbe3

4 files changed

Lines changed: 21 additions & 8 deletions

File tree

.github/workflows/docs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ jobs:
1414
- uses: actions/setup-python@v4
1515
with:
1616
python-version: '3.8'
17-
- run: pip install -r dev-requirements.txt
17+
- uses: abatilo/actions-poetry@v2
18+
- run: poetry install
1819
- run: ./pdoc.sh
1920
- uses: actions/upload-pages-artifact@v2
2021
with:

jellyfish/_notifier.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,16 @@ class Notifier:
2222
'''
2323

2424
def __init__(self,
25-
server_address: str = 'localhost:5002', server_api_token: str = 'development'):
26-
self._server_address = server_address
25+
server_address: str = 'localhost:5002',
26+
server_api_token: str = 'development',
27+
secure: bool = False):
28+
'''
29+
Create Notifier instance, providing the jellyfish address and api token.
30+
Set secure to `True` for `wss` and `False` for `ws` connection (default).
31+
'''
32+
33+
protocol = 'wss' if secure else 'ws'
34+
self._server_address = f'{protocol}://{server_address}/socket/server/websocket'
2735
self._server_api_token = server_api_token
2836
self._websocket = None
2937
self._ready = False
@@ -61,8 +69,7 @@ async def connect(self):
6169
The handlers have to be defined before calling `connect`,
6270
otherwise the messages won't be received.
6371
'''
64-
address = f'ws://{self._server_address}/socket/server/websocket'
65-
async with client.connect(address) as websocket:
72+
async with client.connect(self._server_address) as websocket:
6673
try:
6774
self._websocket = websocket
6875
await self._authenticate()

jellyfish/_room_api.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@ class RoomApi:
1515
'''Allows for managing rooms'''
1616

1717
def __init__(self,
18-
server_address: str = 'localhost:5002', server_api_token: str = 'development'):
18+
server_address: str = 'localhost:5002',
19+
server_api_token: str = 'development',
20+
secure: bool = False):
1921
'''
2022
Create RoomApi instance, providing the jellyfish address and api token.
23+
Set secure to `True` for `https` and `False` for `http` connection (default).
2124
'''
25+
26+
protocol = 'https' if secure else 'http'
2227
self._configuration = jellyfish_api.Configuration(
23-
host=f'http://{server_address}',
28+
host=f'{protocol}://{server_address}',
2429
access_token=server_api_token
2530
)
2631

pdoc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pdoc\
1+
poetry run pdoc \
22
--favicon https://logo.swmansion.com/membrane/\?width\=100\&variant\=signetDark\
33
--logo https://logo.swmansion.com/membrane/\?width\=70\&variant\=signetDark\
44
-t doc_templates \

0 commit comments

Comments
 (0)