added handling streamSid after first wss connect

fixx name
This commit is contained in:
daniil5701133
2024-06-25 14:40:14 +03:00
parent beced68337
commit dd402da9e5
4 changed files with 17 additions and 11 deletions

View File

@@ -1,3 +1,5 @@
import json
import uvicorn
from fastapi import FastAPI, WebSocket
@@ -26,8 +28,13 @@ async def start_call():
@app.websocket("/ws")
async def websocket_endpoint(websocket: WebSocket):
await websocket.accept()
start_data = websocket.iter_text()
await start_data.__anext__()
call_data = json.loads(await start_data.__anext__())
print(call_data, flush=True)
stream_sid = call_data['start']['streamSid']
print("WebSocket connection accepted")
await run_bot(websocket)
await run_bot(websocket, stream_sid)
if __name__ == "__main__":