main
Browse files
main.py
CHANGED
|
@@ -15,11 +15,15 @@ app.add_middleware(
|
|
| 15 |
allow_headers=["*"],
|
| 16 |
)
|
| 17 |
|
|
|
|
|
|
|
| 18 |
@app.post("/signal")
|
| 19 |
async def signal(request: Request):
|
| 20 |
body = await request.json()
|
| 21 |
offer = body["offer"]
|
|
|
|
| 22 |
pc = RTCPeerConnection()
|
|
|
|
| 23 |
|
| 24 |
@pc.on("datachannel")
|
| 25 |
def on_datachannel(channel):
|
|
|
|
| 15 |
allow_headers=["*"],
|
| 16 |
)
|
| 17 |
|
| 18 |
+
peer_connections = {}
|
| 19 |
+
|
| 20 |
@app.post("/signal")
|
| 21 |
async def signal(request: Request):
|
| 22 |
body = await request.json()
|
| 23 |
offer = body["offer"]
|
| 24 |
+
|
| 25 |
pc = RTCPeerConnection()
|
| 26 |
+
peer_connections[id(pc)] = pc # prevent GC
|
| 27 |
|
| 28 |
@pc.on("datachannel")
|
| 29 |
def on_datachannel(channel):
|