Skip to content

Commit d65aa83

Browse files
committed
apply comment suggestions, refine frontend
1 parent 9d35665 commit d65aa83

File tree

8 files changed

+431
-168
lines changed

8 files changed

+431
-168
lines changed

examples/selective_subscription/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,22 @@ Demo application showing selective subscription functionality with [Fishjam](htt
1010

1111
## Quick Start
1212

13-
1. Install dependencies(in project root):
13+
1. Install dependencies (in the `examples/selective_subscription` directory):
1414
```bash
15+
cd examples/selective_subscription
1516
uv sync
1617
```
1718

1819
2. Run the server:
1920
```bash
2021
FISHJAM_ID=<your-id> \
2122
FISHJAM_MANAGEMENT_TOKEN=<your-token> \
22-
uv run examples/selective_subscription/main.py
23+
uv run main.py
2324
```
2425

2526
3. Open http://localhost:8000 in your browser
2627

27-
## Usage
28+
You create peers using the web UI at [http://localhost:8000](http://localhost:8000).
2829

2930
1. Create peers with names
3031
2. Copy peer tokens and use them with a WebRTC client (e.g., [minimal-react](https://github.com/fishjam-cloud/web-client-sdk/tree/main/examples/react-client/minimal-react))

examples/selective_subscription/pyproject copy.toml

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

examples/selective_subscription/pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ requires-python = ">=3.11"
77
dependencies = [
88
"starlette>=0.35.0",
99
"uvicorn>=0.25.0",
10-
"jinja2>=3.1.0",
11-
"python-multipart>=0.0.6",
10+
"fishjam-server-sdk",
1211
]
1312

13+
[tool.uv.sources]
14+
fishjam-server-sdk = { workspace = true }
15+
1416
[build-system]
1517
requires = ["hatchling"]
1618
build-backend = "hatchling.build"

examples/selective_subscription/selective_subscription/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22

33
FISHJAM_ID = os.environ["FISHJAM_ID"]
44
FISHJAM_TOKEN = os.environ["FISHJAM_MANAGEMENT_TOKEN"]
5-
FISHJAM_URL = os.getenv("FISHJAM_URL", "http://localhost:5002")
65
HOST = os.getenv("HOST", "localhost")
76
PORT = int(os.getenv("PORT", "8000"))

examples/selective_subscription/selective_subscription/room_service.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,18 @@
88

99
class RoomService:
1010
def __init__(self):
11-
self.fishjam = FishjamClient(FISHJAM_ID, FISHJAM_TOKEN)
11+
self.fishjam = FishjamClient(fishjam_id=FISHJAM_ID, management_token=FISHJAM_TOKEN)
1212
self.room = self.fishjam.create_room(
1313
RoomOptions(max_peers=10, room_type="conference")
1414
)
1515

1616
def get_or_create_room(self) -> Room:
17-
if self.room:
18-
try:
19-
room = self.fishjam.get_room(self.room.id)
20-
return room
21-
except NotFoundError:
22-
pass
17+
try:
18+
self.room = self.fishjam.get_room(self.room.id)
19+
except NotFoundError:
20+
self.room = self.fishjam.create_room()
2321

24-
return self.fishjam.create_room()
22+
return self.room
2523

2624
def create_peer(self) -> tuple[Peer, str]:
2725
room = self.get_or_create_room()
@@ -36,16 +34,3 @@ def subscibe_peer(self, peer_id: str, target_peer_id: str):
3634
def subscribe_tracks(self, peer_id: str, track_ids: List[str]):
3735
room = self.get_or_create_room()
3836
self.fishjam.subscribe_tracks(room.id, peer_id, track_ids)
39-
40-
def get_peer_session(self, peer_id: str):
41-
room = self.get_or_create_room()
42-
for p in room.peers:
43-
if p.id == peer_id:
44-
45-
class _Session:
46-
def __init__(self):
47-
self.subscribed_peers: set[str] = set()
48-
49-
return _Session()
50-
51-
return None

0 commit comments

Comments
 (0)