Add logic to only forward the first on_dialin_ready event

This commit is contained in:
Mark Backman
2025-04-27 14:21:14 -04:00
parent 53887b7c98
commit f24a85cc94
3 changed files with 15 additions and 4 deletions

View File

@@ -21,10 +21,10 @@ load_dotenv()
@asynccontextmanager
async def lifespan(app: FastAPI):
# Create aiohttp session to be used for Daily API calls
app.session = aiohttp.ClientSession()
app.state.session = aiohttp.ClientSession()
yield
# Close session when shutting down
await app.session.close()
await app.state.session.close()
app = FastAPI(lifespan=lifespan)
@@ -51,7 +51,7 @@ async def handle_call(request: Request):
# Create a Daily room with SIP capabilities
try:
room_details = await create_sip_room(request.app.session, caller_phone)
room_details = await create_sip_room(request.app.state.session, caller_phone)
except Exception as e:
print(f"Error creating Daily room: {e}")
raise HTTPException(status_code=500, detail=f"Failed to create Daily room: {str(e)}")