Major feature update: Add IRC-style chat, performance optimizations, and mobile support

🚀 New Features:
- Real-time IRC-style text chat with commands (/me, /clear, /help, etc.)
- Full mobile optimization with responsive design and touch controls
- Performance monitoring and adaptive video quality
- Configuration-driven settings with config.json

💬 Chat System:
- IRC-style formatting with timestamps and usernames
- Mobile full-screen chat overlay
- Join/leave notifications and system messages
- Message history with automatic cleanup
- Desktop side panel + mobile overlay sync

📱 Mobile Optimizations:
- Touch-friendly controls with emoji icons
- Progressive Web App meta tags
- Orientation change handling
- Mobile-optimized video constraints
- Dedicated mobile chat interface

 Performance Improvements:
- Adaptive video quality based on network conditions
- Video element pooling and efficient DOM operations
- Connection quality monitoring with visual indicators
- Enhanced peer connection management and cleanup
- SDP optimization for better codec preferences

🔧 Technical Changes:
- Renamed main.js to script.js for better organization
- Added comprehensive configuration system
- Fixed port mismatch (3232) and dynamic connection handling
- Improved ICE candidate routing and WebRTC stability
- Enhanced error handling and resource cleanup

🎨 UI/UX Improvements:
- Modern responsive design with light/dark themes
- Connection quality indicator in header
- Better button styling with icons and text
- Mobile-first responsive breakpoints
- Smooth animations and touch feedback
This commit is contained in:
2025-10-02 20:01:03 +01:00
parent 209c690413
commit 357ed5798e
7 changed files with 2051 additions and 441 deletions

31
app.py
View File

@@ -24,10 +24,18 @@ def handle_connect(auth):
def handle_disconnect():
from flask import request
print(f'Client disconnected: {request.sid}') # type: ignore
username = None
if request.sid in connected_clients: # type: ignore
username = connected_clients[request.sid].get('username') # type: ignore
del connected_clients[request.sid] # type: ignore
# Notify other clients about disconnection
emit('user_disconnected', {'id': request.sid}, broadcast=True, include_self=False) # type: ignore
# Notify chat about user leaving
if username:
emit('user_left_chat', {'username': username}, broadcast=True, include_self=False)
@socketio.on('offer')
def handle_offer(data):
@@ -48,7 +56,8 @@ def handle_answer(data):
def handle_ice_candidate(data):
from flask import request
print(f'Received ICE candidate from {request.sid}') # type: ignore
# Broadcast ICE candidate to all other clients or specific client
# Add sender ID to the data and send to target
data['id'] = request.sid # type: ignore
if 'target_id' in data:
emit('ice_candidate', data, to=data['target_id'])
else:
@@ -83,11 +92,29 @@ def handle_join_room(data=None):
'id': request.sid, # type: ignore
'username': username
}, broadcast=True, include_self=False)
# Notify chat about new user
emit('user_joined_chat', {
'username': username
}, broadcast=True, include_self=False)
@socketio.on('chat_message')
def handle_chat_message(data):
from flask import request
print(f'Chat message from {request.sid} ({data.get("username", "Unknown")}): {data.get("message", "")}') # type: ignore
# Broadcast message to all other clients (sender already displayed it locally)
emit('chat_message', {
'username': data.get('username', 'Unknown'),
'message': data.get('message', ''),
'timestamp': data.get('timestamp', __import__('time').time() * 1000),
'sender_id': request.sid # type: ignore
}, broadcast=True, include_self=False)
if __name__ == '__main__':
# Set up SSL context
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.load_cert_chain('cert.pem', 'key.pem')
print("Starting Flask-SocketIO server on https://localhost:3000")
print("Starting Flask-SocketIO server on https://localhost:3232")
socketio.run(app, host='0.0.0.0', port=3232, ssl_context=context, debug=True)