announce when a username leaves the room.

modified:   app.py
	modified:   templates/chat.html
This commit is contained in:
Russell Ballestrini 2024-11-24 13:32:08 -05:00
parent c937c7b2c3
commit 96c10fc6d6
2 changed files with 8 additions and 1 deletions

6
app.py
View file

@ -542,7 +542,13 @@ def on_disconnect():
room = Room.query.filter_by(name=room_name).first()
room.remove_user(username)
leave_room(room_name)
# Broadcast to all clients in the room that a user has left the room.
emit("active_users", {"users": room.get_active_users()}, room=room_name)
emit(
"chat_message",
{"id": None, "content": f"{username} has left the room."},
room=room.name,
)
# Remove session data from the database
db.session.delete(user_session)
db.session.commit()

View file

@ -36,6 +36,7 @@
<option value="claude-haiku">claude-haiku</option>
<option value="claude-sonnet">claude-sonnet</option>
<option value="claude-opus">claude-opus</option>
<option value="dall-e-3">dall-e-3</option>
</select>
</div>
<div>
@ -70,7 +71,7 @@ const VALID_VOICES = ['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'];
const VALID_MODELS = [
'None', 'gemini-flash', 'gemini-flash-8b', 'gemini-pro', 'grok-beta',
'vllm/hermes-llama-3', 'gpt-4', 'gpt-4o-2024-08-06', 'gpt-mini',
'gpt-o1-mini', 'claude-haiku', 'claude-sonnet', 'claude-opus'
'gpt-o1-mini', 'claude-haiku', 'claude-sonnet', 'claude-opus', 'dall-e-3'
];
// Configuration for DOMPurify to specify which tags and attributes are allowed